namespace Exception
<?php //example04.php /*When catching an exception inside a namespace it is important that you escape to the global space: 如何逃离出命名空间*/ namespace SomeNamespace; class SomeClass { function SomeFunction() { try { throw new \Exception('Some Error Message'); } catch (\Exception $e) { var_dump($e->getMessage()); } } } //报错://Fatal error: Class 'SomeNamespace/Exception' not found in ... $o=new SomeClass; $o->SomeFunction(); /* string 'Some Error Message' (length=18) */

浙公网安备 33010602011771号