note 119546 added to class.runtimeexception
| From: | sricharan dot krishnan at gmail dot com | Date: | Mon, 04 Jul 2016 10:41:34 +0000 |
| Subject: | note 119546 added to class.runtimeexception | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-205875@lists.php.net to get a copy of this message | ||
A simple example of using RuntimeException Class:-
Lets say we would be dividing two numbers and throw an exception as soon as the denominator is equal
to zero.
<?php
$iNum1 = 10;
$iNum2 = 0;
try{
if ($iNum2 == 0){
throw new RuntimeException("Division by Zero");
}
$iResult = $iNum1 / $iNum2;
echo ("Division Result of \$iNum1 and $iNum2 = ".($iResult)."<br/>");
}
catch (RuntimeException $e){
echo ("Division by Zero is not possible");
}
?>
----
Server IP: 72.52.91.14
Probable Submitter: 49.207.188.207
----
Manual Page -- http://php.net/manual/en/class.runtimeexception.php
Edit -- https://master.php.net/note/edit/119546
Del: integrated -- https://master.php.net/note/delete/119546/integrated
Del: useless -- https://master.php.net/note/delete/119546/useless
Del: bad code -- https://master.php.net/note/delete/119546/bad+code
Del: spam -- https://master.php.net/note/delete/119546/spam
Del: non-english -- https://master.php.net/note/delete/119546/non-english
Del: in docs -- https://master.php.net/note/delete/119546/in+docs
Del: other reasons-- https://master.php.net/note/delete/119546
Reject -- https://master.php.net/note/reject/119546
Search -- https://master.php.net/manage/user-notes.php