strtr
strtr() 函数转换字符串中/数组中特定的字符。
<?php
$arr = array("Hello" => "Hi", "world" => "earth");
echo strtr("Hello world",$arr)
;
?>
输出:
Hi earth
The file_put_contents() writes a string to a file. file_put_contents()函数的作用是:将一个字符串写入文件。
var_export
描述
mixed var_export ( mixed expression [, bool return])
此函数返回关于传递给该函数的变量的结构信息,它和 var_dump() 类似,不同的是其返回的表示是合法的 PHP 代码。
您可以通过将函数的第二个参数设置为 TRUE ,从而返回变量的表示。
- function cache_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?>" ;
- }
- }
- $strlen = file_put_contents(PHPCMS_CACHEDIR.$file, $string);
- chmod(PHPCMS_CACHEDIR.$file, 0777 );
- return $strlen;
- }