Get webroot in PHP

前端 未结 4 903
不知归路
不知归路 2021-01-06 03:03

I am using Apache server for PHP. How can I retrieve my web root in PHP, like http://localhost/testthesis/?

4条回答
  •  执念已碎
    2021-01-06 03:45

    Here is one way of doing it:

    $web_root = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/";
    
    OUTPUT -->http://website.com/parent_folder/
    

提交回复
热议问题