PHP的文件缓存一般有2种实现方式. 1.直接将需要缓存的数据写入php脚本文件进行缓存,然后以include的方式读取,代码如下: <?php //test_include_write.php //$user为需要缓存的数组文件 $user = array('name'=>'jc','sex'=>'male','age'=>24,'company'=>'xxx.com','offer'=>'php'); //$content为将要写入文件的内容 $content = "<?php/r/n"; $content .= '$user = array(/'name/'=>/'jc/',/'sex/'=>/'male/',/'age/'=>24,/'company/'=>/'766.com/',/'offer/'=>/'php/');'."/r/n"; $content .= '?>'; //写入缓存 file_put_contents('cache_include.php',$content); ?> <?php //test_include_read.php //以include