PHP - Document_Root vs Sub-Domains

喜欢而已 提交于 2019-12-06 15:50:50

You could do something in your bootstrap file:

define( 'ROOT_PATH', dirname( dirname( __FILE__ ) ) );

This obviously depends on if the first file to run is in a subdirectory or not.

e.g.

/docroot
- index.php --> define( 'ROOT_PATH', dirname( dirname( __FILE__ ) ) );

/docroot
- /common
- - index.php --> define( 'ROOT_PATH', dirname( dirname( dirname( __FILE__ ) ) ) );

A side note, this is really meant as a way to correctly access your applications files and not necessarily determine if you are in the document root of your web server. Anyway hope this helps, or at least gives you some ideas.

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