21,891
社区成员
发帖
与我相关
我的任务
分享
<?php
file_put_contents("1.txt","aabbcc",LOCK_EX);
$a = file_get_contents('1.txt');
echo $a;
?>
file_put_contents('zzz', 'a');
$s = file_get_contents('zzz');
echo $s;
$fp = fopen('zzz', 'w');
fwrite($fp, 'b');
$fp = fopen('zzz', 'r');
echo fgets($fp);ab
public function set($id,$value,$expire=0)
{
//echo "<pre>";echo "a";print_r($value);exit();
file_put_contents($this->getFile($id),'<?php return array('.$expire.','.var_export($value, true).');',LOCK_EX);
}
public function get($id)
{
$cFile = $this->getFile($id);
if (file_exists($cFile))
{
$data = include $cFile;
if(SYSTIME < $data[0] || $data[0] == 0)
{
return $data[1];
}else
{
@unlink($cFile);
}
}
return false;
}
file_put_contents($this->getFile($id),'<?php return array('.$expire.','.var_export($value, true).');',LOCK_EX);
$urlArray = cache::get('tuangouBaiduType');
echo "<pre>a";print_r($urlArray); //$urlArray 为 空
if(count($urlArray)<=1){
cache::init("php");
$type = array('a','b','c','d');
cache::set('tuangouBaiduType',$type);
}
cache::init("php");
$urlArray = cache::get('tuangouBaiduType');
echo "<pre>d";print_r($urlArray); // $urlArray的内容为空 并不是 'a','b','c','d'
大约就是这样的