try and catch block in php
Thursday, October 30, 2008 8:47Exception handling is used to change the normal flow of the code execution if a specified error (exceptional) condition occurs. This condition is called an exception.
Try block is used to try for the code to execute if any error like file unable to open etc.. It will stop the execution and it will throw exception like file not found exception.. We can catch this exception in catch block.. If try will not throw any exception catch block never execute.
try {
//open a file which is not existing
$row = $this->db->fetchRow( $sql );
return $row;
}
catch( Exception $e ) {
// does some custom error handling
mysqlErrorCheck( $e, __LINE__, __FILE__ );
}

