代碼如下 |
複製代碼 |
$str = "<?php $list = " . var_export($list) . "; ?>"; //寫入temp.inc.php $file = 'temp.inc.php'; $fo = fopen($file, 'w'); fwrite($fl, $str); fclose($fo); |
代碼如下 |
複製代碼 |
function arrayeval($array, $level = 0) { $space = " "; for($i = 0; $i <= $level; $i++) { $space .= " "; } $evaluate = "array $space( "; $comma = "$space"; if(!empty($array)){ foreach($array as $key => $val) { $val = empty($val)?' ':$val; $key = is_string($key) ? "'".addcslashes($key, ''\')."'" : $key; $val = is_string($val) ? "'".addcslashes($val, ''\')."'" : $val; if(is_array($val)) { $evaluate .= "$comma$key => ".arrayeval($val, $level + 1); } else { $evaluate .= "$comma$key => $val"; } $comma = ", $space"; } } $evaluate .= " $space)"; return $evaluate; } |
$file="./www.111cn.net/file.cache";
$array = array("count" => "3000", "num" =>"300");
//緩衝
代碼如下 |
複製代碼 |
file_put_contents($file,serialize($array));//寫入緩衝 $handle = fopen($file, "r"); $cachearray = unserialize(fread($handle, filesize ($file))); print_r($cachearray); |