Skip to content

Instantly share code, notes, and snippets.

@Reinmar
Created October 19, 2011 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Reinmar/1298274 to your computer and use it in GitHub Desktop.
Save Reinmar/1298274 to your computer and use it in GitHub Desktop.
PHP sucks
<?php
namespace x;
require 'catch_me2.php';
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
try {
\y\shittyCode();
}
catch (Exception $e) {
echo 'Gotcha!';
}
//Guess what? Uncaught exception 'Exception' with message 'catch me if you can' :)
//No error caused by lack of Exception class in this namespace
<?php
namespace y;
function shittyCode() {
throw new \Exception('catch me if you can');
}
@Reinmar
Copy link
Author

Reinmar commented Oct 19, 2011

I know I can, but then it wouldn't be so tricky :> In the case I was working on the exception was thrown far far away, so it took me a while before I've found wtf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment