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条)

报告相同问题?

悬赏问题

  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程