2016-12-31 112 views
0

说的确切目录我跑如何获得一个脚本

http://mymaindomain.com/helloworld/somescript.php

我想http://mymaindomain.com/helloworld/

我该怎么办呢?

+0

不是机器内部的目录,但面对公众的目录。所以不是/ root/htdocs/public_html/helloworld /更像http://domainname.com/helloworld/ –

+0

可能重复的[获取当前脚本的绝对路径](http://stackoverflow.com/questions/4645082/get-绝对路径当前脚本) –

+0

http://php.net/manual/en/reserved.variables.server.php – leaf

回答

1

你能检查我的答案吗?

https://stackoverflow.com/a/41407858/3821823

你也可以这样定义常量变量:

const BASE_URL = 'http://mymaindomain.com/helloworld/'; 
// or 
define('BASE_URL', 'http://mymaindomain.com/helloworld/'); 

echo BASE_URL;