Home > Backend Development > PHP Tutorial > 定义这个函数为什么会报错

定义这个函数为什么会报错

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 12:14:04
Original
1204 people have browsed it

定义这个函数为什么会出错
老是提示这个错误: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']                     {
                        $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有些东西不支持,建议更换版本。
------解决思路----------------------
语法错误,仔细检查一下吧
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template