dirname(__FILE__) on localhost

后端 未结 3 1342
北恋
北恋 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:46

    It looks like you just need to have

    define('PATH', $_SERVER['SERVER_NAME']);
    

    If you want to be super technical, you can do something like this instead.

    define('PATH', str_replace($_SERVER['DOCUMENT_ROOT'], $_SERVER['SERVER_NAME'] . '/', dirname(__FILE__)));
    

    On a side note, and more importantly, you don't actually need them. This will work.

    
    

    When a href begins with a directory separator, it is considered relative to the document root, not the current working directory.

提交回复
热议问题