Forum PHP 2017

Voting

Please answer this simple SPAM challenge: nine minus four?
(Example: nine)

The Note You're Voting On

jim at anderos dot com
3 years ago
If you are using a namespace, you must indicate the global namespace when using Exceptions.
<?php
namespace alpha;
function
foo(){
    throw new \
Exception("Something is wrong!");
   
// throw new Exception(""); will fail
}

try {
   
foo();
} catch( \
Exception $e ) {
   
// catch( Exception $e ) will give no warning, but will not catch Exception
   
echo "ERROR: $e";
}

?>

<< Back to user notes page

To Top