Skip to content

Instantly share code, notes, and snippets.

@bjzhush
Created August 1, 2015 07:41
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 bjzhush/e318928d91007de2e042 to your computer and use it in GitHub Desktop.
Save bjzhush/e318928d91007de2e042 to your computer and use it in GitHub Desktop.
Using namespaces: fallback to global function/constant
<?php
namespace A\B\C;
class Exception extends \Exception {}
$a = new Exception('hi'); // $a is an object of class A\B\C\Exception
$b = new \Exception('hi'); // $b is an object of class Exception
$c = new ArrayObject; // fatal error, class A\B\C\ArrayObject not found
//http://php.net/manual/en/language.namespaces.fallback.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment