将config.php修改如下:
<?php
function getpath(){
$mainpath=$_SERVER['DOCUMENT_ROOT']; var_dump($mainpath);echo '<br/>';
$filepath=$_SERVER['SCRIPT_FILENAME']; var_dump($filepath);echo '<br/>';
$array=explode("/",$filepath);
$newarray=array();
for($i=0;$i<count($array)-1;$i++){
array_push($newarray,$array[$i]."/");
}
$abspath=implode("",$newarray); var_dump($abspath);echo '<br/>';
$num=strlen($mainpath)-strlen($abspath); var_dump($num);echo '<br/>';
$newpathtmp=substr($abspath,$num); var_dump($newpathtmp);echo '<br/>';
$newpath=$newpathtmp."Smarty/"; var_dump($newpath);echo '<br/>';
return($newpath);
}
$path=getpath();
//var_dump($path);
?>
出错信息为:
string(17) "/var/www/c868c.cn"
string(33) "/var/www/c868c.cn/mr/12/index.php"
string(24) "/var/www/c868c.cn/mr/12/"
int(-7)
string(7) "/mr/12/"
string(14) "/mr/12/Smarty/"
Fatal error: Call to a member function assign() on a non-object in /var/www/c868c.cn/mr/12/top.php on line 14