Get parent directory of running script

后端 未结 13 2035
攒了一身酷
攒了一身酷 2020-11-30 04:20

In PHP, what would be the cleanest way to get the parent directory of the current running script relative to the www root? Assume I have:

$_         


        
13条回答
  •  渐次进展
    2020-11-30 05:01

    I Hope this will help you.

    echo getcwd().'
    '; // getcwd() will return current working directory echo dirname(getcwd(),1).'
    '; echo dirname(getcwd(),2).'
    '; echo dirname(getcwd(),3).'
    ';

    Output :

    C:\wamp64\www\public_html\step
    C:\wamp64\www\public_html
    C:\wamp64\www
    C:\wamp64
    

提交回复
热议问题