June 2002
Intermediate to advanced
800 pages
16h 3m
English
Exception handling is a core feature of almost any programming language. Exception handling is not only necessary to detect errors but also for flow control. PHP provides a powerful exception-handling model that can easily be used by programmers. To show you how exception handling can be done, we have included a simple example:
<?php
$a = "a string";
if (sqrt($a))
{
echo "Result: $b";
}
else
{
echo "The operation cannot be performed";
}
?>
First, a string is defined. Then the script tries to compute the square root of the string, which is not possible. Therefore the condition evaluated by the if statement is not true and the else branch is entered.
If something happens that is not allowed in the script, it is necessary ...
Read now
Unlock full access