Autoload with namespaces in PHP 5.3?

拜拜、爱过 提交于 2019-12-06 17:42:54

问题


How do you use _autoload in PHP 5.3 with namespaces? I have a main autoload function in a namespace separate from my script. I'm also calling a class with a different namespace. (It's not surprising, but) It's not finding the autoload function. Do I have to recreate the autoload function for each namespace? That seems suboptimal.

Thanks in advance for any help!


回答1:


From a comment in the PHP manual:

To use autoload function with namespaces you should remember to define it in main scope in "\" namespace.



来源:https://stackoverflow.com/questions/1354944/autoload-with-namespaces-in-php-5-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!