25.09.2014 Views

ZEND PHP 5 Certification STUDY GUIDE

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Object Oriented Programming in <strong>PHP</strong> ” 129<br />

class Exception {<br />

// The error message associated with this exception<br />

protected $message = ’Unknown Exception’;<br />

// The error code associated with this exception<br />

protected $code = 0;<br />

// The pathname of the file where the exception occurred<br />

protected $file;<br />

// The line of the file where the exception occurred<br />

protected $line;<br />

// Constructor<br />

function __construct ($message = null, $code = 0);<br />

// Returns the message<br />

final function getMessage();<br />

// Returns the error code<br />

final function getCode();<br />

// Returns the file name<br />

final function getFile();<br />

// Returns the file line<br />

final function getLine();<br />

// Returns an execution backtrace as an array<br />

final function getTrace();<br />

// Returns a backtrace as a string<br />

final function getTraceAsString();<br />

// Returns a string representation of the exception<br />

function __toString();<br />

}<br />

Licensed to 482634 - Amber Barrow (itsadmin@deakin.edu.au)<br />

Almost all of the properties of an Exception are automatically filled in for you by the<br />

interpreter—generally speaking, you only need to provide a message and a code, and<br />

all the remaining information will be taken care of for you.<br />

Since Exception is a normal (if built-in) class, you can extend it and effectively create<br />

your own exceptions, thus providing your error handlers with any additional information<br />

that your application requires.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!