我的系统是linux,根据老师提供的程序修改了config.php,出错信息为:Parse error: syntax error, unexpected '$mainpath' (T_VARIABLE) in /var/www/c868c.cn/mr/12/config.php on line 3
我的网址为c868c.cn/mr/12
程序如下:
<?php
function getpath(){
$mainpath=$_SERVER['DOCUMENT_ROOT'];
$filepath=$_SERVER['SCRIPT_FILENAME'];
$array=explode("/",$filepath);
$newarray=array();
for($i=0;$i<count($array)-1;$i++){
array_push($newarray,$array[$i]."/");
}
$abspath=implode("",$newarray);
$num=strlen($mainpath)-strlen($abspath);
$newpathtmp=substr($abspath,$num);
$newpath=$newpathtmp."Smarty/";
return($newpath);
}
$path=getpath();
define('BASE_PATH',$_SERVER['DOCUMENT_ROOT']);
define('SMARTY_PATH',$path);
require BASE_PATH.SMARTY_PATH.'libs/Smarty.class.php';
$smarty = new Smarty;
$smarty->template_dir = BASE_PATH.SMARTY_PATH.'templates/';
$smarty->compile_dir = BASE_PATH.SMARTY_PATH.'templates_c/';
$smarty->config_dir = BASE_PATH.SMARTY_PATH.'configs/';
$smarty->cache_dir = BASE_PATH.SMARTY_PATH.'cache/';
?>