note 106696 added to language.exceptions
| From: | Sawsan at osu1 dot php dot net | Date: | Tue, 29 Nov 2011 05:36:00 +0000 |
| Subject: | note 106696 added to language.exceptions | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-184751@lists.php.net to get a copy of this message | ||
the following is an example of a re-thrown exception and the using of getPrevious function:
<?php
$name = "Name";
//check if the name contains only letters, and does not contain the word name
try
{
try
{
if (preg_match('/[^a-z]/i', $name))
{
throw new Exception("$name contains character other than a-z A-Z");
}
if(strpos(strtolower($name), 'name') !== FALSE)
{
throw new Exception("$name contains the word name");
}
echo "The Name is valid";
}
catch(Exception $e)
{
throw new Exception("insert name again",0,$e);
}
}
catch (Exception $e)
{
if ($e->getPrevious())
{
echo "The Previous Exception is:
".$e->getPrevious()->getMessage()."<br/>";
}
echo "The Exception is: ".$e->getMessage()."<br/>";
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 46.185.222.165
----
Manual Page -- http://www.php.net/manual/en/language.exceptions.php
Edit -- https://master.php.net/note/edit/106696
Del: integrated -- https://master.php.net/note/delete/106696/integrated
Del: useless -- https://master.php.net/note/delete/106696/useless
Del: bad code -- https://master.php.net/note/delete/106696/bad+code
Del: spam -- https://master.php.net/note/delete/106696/spam
Del: non-english -- https://master.php.net/note/delete/106696/non-english
Del: in docs -- https://master.php.net/note/delete/106696/in+docs
Del: other reasons-- https://master.php.net/note/delete/106696
Reject -- https://master.php.net/note/reject/106696
Search -- https://master.php.net/manage/user-notes.php