Skip to content

Instantly share code, notes, and snippets.

@antonioribeiro antonioribeiro/t1.php
Last active Aug 29, 2015

Embed
What would you like to do?
<?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
You can’t perform that action at this time.