- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.php
More file actions
Latest commit
28 lines (24 loc) · 508 Bytes
/
Copy pathfunction.php
File metadata and controls
28 lines (24 loc) · 508 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
functioninverse($x) {
if (!$x) {
thrownewDivisionByZeroError('Division by zero.');
}
return1/$x;
}
try {
echoinverse(5) . "\n";
} catch (Exception$e) {
echo'Caught exception: ', $e->getMessage(), "\n";
} finally {
echo"First finally.\n";
}
try {
echoinverse(0) . "\n";
} catch (DivisionByZeroError$e) {
echo'Caught exception: ', $e->getMessage(), "\n";
} finally {
echo"Second finally.\n";
}
// Continue execution
echo"Hello World\n";
?>