PHP 5 supports the concept of exceptions via try and catch.

<?php
try {
    $d = 1 / 0;
    print $d;
} catch (Exception $e) {
    die("There was an error: " . 
        $e->getException());
}
?>
Custom Exceptions are also supported.

<?php  
class MyException {
    function MyException($_error) 
    {
        $this->error = $_error;
    }

    function getException()
    {
        return $this->error;
    }
}
    
function ThrowException()
{   
    throw new MyException("'This is an exception!'");
}

try {
    ThrowException();
} catch (MyException $exception) {
    print "There was an exception: " . $exception->getException();
    print "\n";
}
?>