Including files using relative paths with PHP?

后端 未结 4 658
暖寄归人
暖寄归人 2020-12-12 06:50

When developing my website I called all the includes in my php files by calling one single file called includes.

The code of this file looked somethig like this: (I

4条回答
  •  悲哀的现实
    2020-12-12 07:28

    First off: I'd drop the DS, it's BS (ehe). Windows support both C:/wamp/www and C:\wamp\www :-) Even C:\wamp\www/project is fine.

    If includes.php is located in, say lib/includes.php (relative to your project root), then do this:

    define('SITE_ROOT', realpath('../'));
    

    That will dynamically set SITE_ROOT.

提交回复
热议问题