Skip to content

Instantly share code, notes, and snippets.

@antonioribeiro
Last active August 29, 2015 14:02
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 antonioribeiro/7d4feb011b2e61599544 to your computer and use it in GitHub Desktop.
Save antonioribeiro/7d4feb011b2e61599544 to your computer and use it in GitHub Desktop.
<?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);
}
}
}
<?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