Hoi,
onderstaand stukje code catcht de exception niet... Krijg gewoon de volgende melding in mijn browser:
Fatal error: Uncaught exception 'Exception' with message 'Value must be 1 or below' ....
Iemand enig idee waarom dit simpel voorbeeld niet werkt :-s
Greetz,
J.
onderstaand stukje code catcht de exception niet... Krijg gewoon de volgende melding in mijn browser:
Fatal error: Uncaught exception 'Exception' with message 'Value must be 1 or below' ....
PHP:
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
| <?php //create function with an exception function checkNum($number) { if($number>1) { throw new Exception("Value must be 1 or below"); } return true; } //trigger exception in a "try" block try { checkNum(2); //If the exception is thrown, this text will not be shown echo 'If you see this, the number is 1 or below'; } //catch exception catch(Exception $e) { echo 'Message: ' .$e->getMessage(); } ?> |
Iemand enig idee waarom dit simpel voorbeeld niet werkt :-s
Greetz,
J.