note 88253 added to language.exceptions.extending

From: Date: Sat, 17 Jan 2009 09:32:00 +0000
Subject: note 88253 added to language.exceptions.extending
Groups: php.notes 
Request: Send a blank email to php-notes+get-149364@lists.php.net to get a copy of this message
I have written similar simple custom exception class. Helpful for newbie. <?php /* This is written for overriding the exceptions. custom exception class */ error_reporting(E_ALL-E_NOTICE); class myCustomException extends Exception { public function __construct($message, $code=0) { parent::__construct($message,$code); } public function __toString() { return "<b style='color:red'>".$this->message."</b>"; } } class testException { public function __construct($x) { $this->x=$x; } function see() { if($this->x==9 ) { throw new myCustomException("i didnt like it"); } } } $obj = new testException(9); try{ $obj->see(); } catch(myCustomException $e) { echo $e->__toString(); } ?> ---- Server IP: 59.162.86.33 Probable Submitter: 116.72.118.240 ---- Manual Page -- http://www.php.net/manual/en/language.exceptions.extending.php Edit -- https://master.php.net/note/edit/88253 Del: integrated -- https://master.php.net/note/delete/88253/integrated Del: useless -- https://master.php.net/note/delete/88253/useless Del: bad code -- https://master.php.net/note/delete/88253/bad+code Del: spam -- https://master.php.net/note/delete/88253/spam Del: non-english -- https://master.php.net/note/delete/88253/non-english Del: in docs -- https://master.php.net/note/delete/88253/in+docs Del: other reasons-- https://master.php.net/note/delete/88253 Reject -- https://master.php.net/note/reject/88253 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#149364) next »