dirname(__FILE__) on localhost

后端 未结 3 1316
北恋
北恋 2021-01-06 08:15

I\'m using WAMP and have a development site in the www directory. I want to use dirname(__FILE__) to define the path to the server root.

Currently I\'m

3条回答
  •  执念已碎
    2021-01-06 08:25

    $server = str_replace('\\','/',$_SERVER['SERVER_NAME']);
    $server = (substr($server,-1)=='/'?substr($server,0,strlen($server)-1):$server);
    !defined('PATH')?define('PATH', 'http://'.str_replace($_SERVER['DOCUMENT_ROOT'],$server , str_replace('\\','/',dirname(__FILE__)))):'';
    

提交回复
热议问题