定義這個函數為什麼會報錯

來源:互聯網
上載者:User
定義這個函數為什麼會出錯
老是提示這個錯誤: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有些東西不支援,建議更換版本。
------解決思路----------------------
語法錯誤,仔細檢查一下吧
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.