Php try / catch
Posted: Sat Nov 21, 2009 8:08 am
Hi everybody, i am new to this forum and hope that it will help with my learning of Php.
I have created my first try/catch block like the following.
Well, it generates an error, but it never enter the catch block. In other programming language, if an error occur in a try block, you automatically go to the catch block, but in php i need to do some validation and throw an exception.
Is this suppose to work like this or am i doing something wrong.
I am currently testing on Wamp, with Php 5.3.0
If someone have clue, please share.
Thank you.
I have created my first try/catch block like the following.
Code: Select all
function test(){
try{
$value = $r ; // The variable $r do not exist.
}catch( Exception $error ){
echo "Catch block" ;
}
}Is this suppose to work like this or am i doing something wrong.
I am currently testing on Wamp, with Php 5.3.0
If someone have clue, please share.
Thank you.