php,幾個有用的函式介紹

2021-08-25 10:15:06 字數 893 閱讀 3308

strtr() 函式轉換字串中/陣列中特定的字元。

<?php

$arr = array("hello" => "hi", "world" => "earth");

echostrtr("hello world",$arr);

?>

輸出:

hi earth
the file_put_contents() writes a string to a file.

file_put_contents()函式的作用是:將乙個字串寫入檔案。

(php 4 >= 4.2.0, php 5)

var_export -- 輸出或返回乙個變數的字串表示

mixedvar_export( mixed expression [, bool return])

此函式返回關於傳遞給該函式的變數的結構資訊,它和var_dump()類似,不同的是其返回的表示是合法的 php **。

您可以通過將函式的第二個引數設定為true,從而返回變數的表示。

function cache_write($file, $string, $type =  'array' )  

elseif($type == 'constant' )  

}  

$strlen = file_put_contents(phpcms_cachedir.$file, $string);  

chmod(phpcms_cachedir.$file, 0777 );  

return  $strlen;  

幾個比較有用的php內建函式

級別的小優化之一 優先使用php內建函式 以下幾個是可以用到內建函式的場景 1.filter var函式 類似的還有 的驗證filter var filter validate url 2.prase url函式 解析url 返回各個組成部分 url print r parse url url ec...

有用的php函式

一 檔案靜態化 檔案讀取函式 檔案讀取函式 function php read file name fclose fd return buf 如果知道的是檔案的連線位址的話 fileaddress http localhost filename.html 檔案所在的位址 function php r...

ASP中幾個有用的函式

原出處 江都資訊網論壇 function deletefile filename 刪除檔案 if filename then set fso server.createobject scripting.filesystemobject if fso.fileexists filename then ...