getCode(). ": ". $e->getMessage()."
". " in ". $e->getFile(). " on line ". $e->getLine(). "
"; ?>"> getCode(). ": ". $e->getMessage()."
". " in ". $e->getFile(). " on line ". $e->getLine(). "
"; ?>">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

Error and Exception Handling

Similar presentations


Presentation on theme: "Error and Exception Handling"— Presentation transcript:

1 Error and Exception Handling
Chapter 7 Error and Exception Handling

2 basic_exception.php <?php try { throw new Exception("A terrible error has occurred", 42); } catch (Exception $e) { echo "Exception ". $e->getCode(). ": ". $e->getMessage()."<br />". " in ". $e->getFile(). " on line ". $e->getLine(). "<br />"; ?>

3 basic_exception.php

4 PHP Exception Class

5 User_defined_exception.php <?php
class myException extends Exception { function __toString() return "<table border=\"1\"> <tr> <td><strong>Exception ".$this->getCode()." </strong>: ".$this->getMessage()."<br />"." in ".$this->getFile()." on line ".$this->getLine()." </td> </tr> </table><br />"; }

6 User_defined_exception.php try {
throw new myException("A terrible error has occurred", 42); } catch (myException $m) echo $m; ?>

7 Bob’s Auto Parts


Download ppt "Error and Exception Handling"

Similar presentations


Ads by Google