thinkphp3.2 获取__PUBLIC__绝对路径
Home/Conf/config.php 修改成以下代码
<?php
// 项目路径 C:/www
$ROOT = $_SERVER['DOCUMENT_ROOT'];
// 返回服务器真实路径 C:/www/a/index.php
$Absolute_Path=$_SERVER['SCRIPT_FILENAME'];
// 截取index.php C:/www/a/
$Absolute_Path=str_replace("index.php","",$Absolute_Path);
// 获取绝对路径 /a/
$Absolute_Path= str_replace($ROOT,"",$Absolute_Path);
return array(
//'配置项'=>'配置值'
// 模板
'TMPL_PARSE_STRING' => array(
'__PATH__' => $Absolute_Path, // /a/
'__PUBLIC__' => $Absolute_Path.'/Public', // /a/Public/
),
);
本文详细介绍了如何在ThinkPHP3.2框架中设置和获取项目的绝对路径,包括__PUBLIC__路径的配置方法。通过修改Home/Conf/config.php文件中的TMPL_PARSE_STRING数组,实现对__PATH__和__PUBLIC__变量的正确赋值。

1万+

被折叠的 条评论
为什么被折叠?



