dongwei3172 2012-03-30 06:51
浏览 40
已采纳

如果需要/包含多个文件,它们是否都是同一命名空间的一部分?

I am brand-spanking-new to the namespace concept in php.

The situation: Multiple files in a folder and they all require/include one another for their own purposes.

If i were to place them all in the same namespace, would it still be necessary to have them require/include each other?

I did think of replacing the require/include with "use", but it seems odd to have a file in namespace foo\bar to actually 'use' foo\bar... o_O

PS: I am covering all my bases by asking questions while also searching the net for answers; so if you have any good sources for info/tutorials etc please feel free to share. :D

Thank you, David

  • 写回答

3条回答 默认 最新

  • dongxun1142 2012-03-30 06:55
    关注

    It can get messy with all the includes/requires. The included files on one included file, will be also included on the first one as well, with out explicitly calling it. I would suggest, if you are using OOP approach, start out using the __autoload() magic method. This will save you tons of headaches down the road when you include a file on a page that's already been included elsewhere running on that page and you get a 500 server error because of it.

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

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!