首页> 实战笔录 >PHP开发笔记 >PHP PHP
php自定义函数获取项目目录
作者:小萝卜 2019-03-27 【 PHP 自定义函数 】 浏览 2093
简介php自定义函数获取项目目录
php自定义函数获取项目目录
代码如下:
function getHost(){
$snarr=@explode("/",$_SERVER["SCRIPT_NAME"]);
array_pop($snarr);
array_shift($snarr);
foreach($snarr as $v){
$urlpath.=$v."/";
}
if($snarr[0]!=""){
$rurlpath="/".rtrim($urlpath,"/");
}
$domain_host="http://".$_SERVER['HTTP_HOST'].$rurlpath;
return $domain_host;
}
echo getHost();
很赞哦! (0)
相关文章
- PHP常用数学函数分享
- php获取域名或主机地址、网页地址、网址参数
- 怎么判断PHP属于nts还是ts版?
- PHP自定义数据库操作类
- Namespace declaration statement has to be the very first statement or after any declare call in the
- PHP 中 json_encode中文处理、urlencode方法、post中文乱码
- PHP获取指定年月日开始和结束的时间戳
- _initialize 和 __construct中不能return
- windows环境PHP 如何安装ionCube扩展
- php获取网站运行了多长时间,服务器运行了多长时间,活动持续多长时间
