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; }
时间: 2024-10-08 03:36:55