var_export 掉咋天

来源:互联网 发布:网络大数据分析 编辑:程序博客网 时间:2024/05/21 17:50

var_export     文件缓存经常使用    输出或返回一个变量的字符串表示


    /**     * 写入缓存     *     * @param string $id     * @param mixed $data     * @param array $policy     */    public function set($mode, $id, $data, $expired = -1)    {        if( empty($mode) || empty($id) ){return false;}        $path = $this->getComFilename($mode ,$id);                $expired = ($expired < 0) ? -1 : time() + $expired;        $content = array(            'expired' => $expired,            'data'    => $data,        );        $content = '<?php return ' . var_export($content, true) . ';';        // 写入缓存,并去掉多余空格        file_put_contents($path, $content, LOCK_EX);        // file_put_contents($path, php_strip_whitespace($path), LOCK_EX);        clearstatcache();                $this->_cachelist($path,$mode);//写缓存列表文件        return true;    }


0 0