Namespaces in PHP are scaring me.
I can only imagine some of my developers creating code and using
namespaces - and how do you identify which namespace a function, class
or chunk of code is under?
It looks like you can define namespaces anywhere.
If I'm looking for a specific function, and it's in two include files,
how do you know which namespace the function is written under? Some
sort of manual backtrace?
Is there a magic constant like NAMESPACE or a function that can
return the name of the namespace the code is currently running under?
At the moment I would actually be telling my developers when I switch
over to 5.3.0 to NOT use namespacing. We don't need it in any of our
applications, and it will just complicate things...
Hi!
If I'm looking for a specific function, and it's in two include files,
how do you know which namespace the function is written under? Some
sort of manual backtrace?
Namespaces are local to files.
Is there a magic constant like NAMESPACE or a function that can
return the name of the namespace the code is currently running under?
"namespace the code is currently running under" is meaningless, since
namespace is a compile-time concept. There is NAMESPACE constant
which is equal to currently compiles namespace.
http://www.php.net/manual/en/language.namespaces.nsconstants.php
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com