标签:
function file_write($file, $string, $type = ‘array‘) { if(is_array($string)) { $type = strtolower($type); if($type == ‘array‘) { $string = "<?php\n return ".var_export($string,TRUE).";\n?>"; } elseif($type == ‘constant‘) { $data=‘‘; foreach($string as $key => $value) { $data .= "define(‘".strtoupper($key)."‘,‘".addslashes($value)."‘);\n"; $string = "<?php\n".$data."\n?>"; } } } $filePath = $file; $strlen = file_put_contents($filePath, $string, LOCK_EX); chmod($filePath, 0777); return $strlen; }
标签:
原文地址:http://www.cnblogs.com/gengting/p/5403651.html