Why do fully qualified names have to be used when dynamically assessing namespaced elements?
- 阅读更多 关于 Why do fully qualified names have to be used when dynamically assessing namespaced elements?
问题 I have been trying to understand the chapter Namespaces and dynamic language features from php.net manual. Please consider the following code: namespace Foo; function strstr() { echo "My local ststr method called"; } $a = 'strstr'; $a(); //This would call the global strstr method As per the manual, I have to go $a = 'Foo\strstr' , but I can't find a reason for this. Why can't php interpreter at runtime know that $a = 'strstr'; was defined in the context of namespace Foo , just like executing