How to get the absolute path to the public_html folder?

后端 未结 11 1362
离开以前
离开以前 2020-12-08 14:25
$_SERVER[\'DOCUMENT_ROOT\']

returns

/usr/local/apache/htdocs/

is there a way to get

/home/us         


        
11条回答
  •  借酒劲吻你
    2020-12-08 15:09

    You can also use dirname in dirname to get to where you want to be.

    Example of usage:

    For Joomla, modules will always be installed in /public_html/modules/mod_modulename/

    So, from within a file within the module's folder, to get to the Joomla install-root on any server , I could use: $path = dirname(dirname(dirname(__FILE__)));

    The same goes for Wordpress, where plugins are always in wp-content/plugins/

    Hope this helps someone.

提交回复
热议问题