Last active
August 29, 2015 14:02
-
-
Save antonioribeiro/7d4feb011b2e61599544 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace A { | |
class ClassA { | |
public function doA() | |
{ | |
try | |
{ | |
try | |
{ | |
$b = new \B\ClassB(); | |
} | |
// Add a \ to this one to see it catching the exception at this point | |
catch(Exception $e) | |
{ | |
echo "(1) catched exception without root namespace"; | |
} | |
} | |
// Exception may not be catched by the first one, but will by this one | |
catch(\Exception $e) | |
{ | |
echo "(2) catched exception with root namespace"; | |
} | |
} | |
} | |
} | |
namespace B { | |
class ClassB { | |
public function __construct() | |
{ | |
throw new \Exception("this is an exceptio!", 1); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require "t1.php"; | |
$a = new A\ClassA(); | |
$a->doA(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment