版本 ------解决方案--------------------手册上的一段回复
--------------------------------------------------
a dot schaffhirt at sedna-soft dot de02-Feb-2010 06:24
Just in case you wonder what the practical use of the namespace keyword is...
It can explicitly refer to classes from the current namespace regardless of possibly "use"d classes with the same name from other namespaces. However, this does not apply for functions.
Example:
namespace foo;
class Xyz {}
function abc () {}
?>
namespace bar;
class Xyz {}
function abc () {}
?>
namespace bar;
use foo
------解决方案--------------------Xyz;
use foo
------解决方案--------------------abc;
new Xyz(); // instantiates \foo\Xyz
new namespace
------解决方案--------------------Xyz(); // instantiates \bar\Xyz
abc(); // invokes \bar\abc regardless of the second use statement
------解决方案--------------------foo
------解决方案--------------------abc(); // it has to be invoked using the fully qualified name
?>
(Sorry, I had to use "
------解决方案--------------------" instead of "\", as it was always discarded in the preview, except within a comment.)
Hope, this can save someone from some trouble.
Best regards.
----------------------------------------
------解决方案--------------------PHP5.2中没有命名空间
你可以删去有关“命名空间”的声明部分
退化成普通的类和函数