定義這個函數為什麼會出錯
老是提示這個錯誤:Parse error: syntax error, unexpected 'function' (T_FUNCTION) in D:\wamp\www\myshop\upload\includes\cls_template.php on line 313
我用的是php5.5.12
我只是初哥,代碼是老闆買回來的,運行到這個函數的時候接不上了
/**
* 判斷是否緩衝
*
* @access public
* @param string $filename
* @param sting $cache_id
*
* @return bool
*/
function is_cached($filename,$cache_id = '')
{
$cachename = basename($filename, strrchr($filename, '.')) . '_' . $cache_id;
if ($this->caching == true && $this->direct_output == false)
{
$hash_dir = $this->cache_dir . '/' . substr(md5($cachename), 0, 1);
if ($data = @file_get_contents($hash_dir . '/' . $cachename . '.php'))
{
$data = substr($data, 13);
$pos = strpos($data, '<');
$paradata = substr($data, 0, $pos);
$para = @unserialize($paradata);
if ($para === false || $this->_nowtime > $para['expires'])
{
$this->caching = false;
return false;
};
$this->_expires = $para['expires'];
$this->template_out = substr($data, $pos);
foreach ($para['template'] AS $val)
{
$stat = @stat($val);
if ($para['maketime'] < $stat['mtime'])
{
$this->caching = false;
return false;
}
};
}
else
{
$this->caching = false;
return false;
};
return true;
}
else
{
return false;
}
}
------解決思路----------------------
Parse error: syntax error, unexpected 'function'
語法錯誤,意想不到的“function”
錯誤出現在 cls_template.php 第 313 行之前
你認真檢查一下
------解決思路----------------------
本帖最後由 xuzuning 於 2014-12-29 18:35:09 編輯
return preg_replace_callback("/{([^\}\{\n]*)}/", function($r){return $this->select($r[1]);}, $source);
尾巴怎麼丟了?
------解決思路----------------------
我使用php5.3.10 沒問題,版本太多,ecshop有些東西不支援,建議更換版本。
------解決思路----------------------
語法錯誤,仔細檢查一下吧