Get webroot in PHP

前端 未结 4 931
不知归路
不知归路 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:29

    Web root is always just /. You'd never need the hostname or protocol part, and root can be only root of the server, not some folder or file.

    If you need some path, like /testthesis/ - there are ways, but it has nothing common with web root.

    If you need a filesystem directory for the webroot - it's in the $_SERVER['DOCUMENT_ROOT'] variable.

提交回复
热议问题