PHP致命错误 - yii \ base \ ErrorException

时间:2016-12-19 13:22:58

标签: json function yii2 undefined fatal-error

我已将我的网站上传到fpt,但我无法解决该错误。请帮帮我。

错误是:

PHP致命错误 - yii \ base \ ErrorException

调用未定义的函数yii \ web \ json_encode()

错误在$hash = md5(json_encode($this->rules));

代码是:

public function init()
    {
        parent::init();

        if (!$this->enablePrettyUrl || empty($this->rules)) {
            return;
        }
        if (is_string($this->cache)) {
            $this->cache = Yii::$app->get($this->cache, false);
        }
        if ($this->cache instanceof Cache) {
            $cacheKey = $this->cacheKey;
            $hash = md5(json_encode($this->rules));
            if (($data = $this->cache->get($cacheKey)) !== false && isset($data[1]) && $data[1] === $hash) {
                $this->rules = $data[0];
            } else {
                $this->rules = $this->buildRules($this->rules);
                $this->cache->set($cacheKey, [$this->rules, $hash]);
            }
        } else {
            $this->rules = $this->buildRules($this->rules);
        }
    }

0 个答案:

没有答案