dpd7195 2011-02-04 04:57
浏览 33
已采纳

具有句点的目录是否会基于Zend Framework中的命名空间中断自动加载解析?

I have a folder in my library folder which is named after my website. The folder path is like:

~\www\library\myWebsite.com

If I'm using Zend autoloader to load the namespace of everything in the library path, will I have any trouble autoloading a class from that file with a namespace like this:

\myWebsite.com\myClass::myFunction();

I have looked online for documentation on this and I can't find any info about using periods in this way.

  • 写回答

2条回答 默认 最新

  • dongmi1864 2011-02-04 16:33
    关注

    I tried it and the complication is in PHP. I think Zend is registering the namespace fine, because when I call \Zend_Load_Autoloader::getRegisteredNamespaces() it shows that it's registered. but when I call the static method from the fully qualified namespace, php gives an error of this:

    Fatal error: Undefined constant 'myWebsite' in /home/jesse/www/application/controllers/MyController.php on line 15 
    

    It seems like PHP is terminating the namespace identifier, during parsing, at the . (period character). This is dissapointing because to me having a library named after the website was important to my design.

    I will rename the directory to myWebsitecom or possibly make the .com it's own sub directory like

    myWebsite\com and incorporate that into my namespace tree like: \MyNamespace\Com\MyClass::myFunction();

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据