常用PHP函式

2021-05-14 09:34:24 字數 636 閱讀 2475

這是一些使用頻率比較高的函式,有的來自別人的程式......

1.產生隨機字串函式

function random($length)

return $hash;

}2.擷取一定長度的字串

注:該函式對gb2312使用有效

function wordscut($string, $length ,$sss=0)

for($i = 0; $i < $length; $i++) else

}return $wordscut.$addstr;

}return $string;

}3.取得客戶端ip位址

function getip()

4.建立相應的資料夾

function createdir($dir='')

7.分頁(兩個函式配合使用)

function getpage($sql,$page_size=20)

function showbar($string="")

if($end<$totalpage)

$out.=">>..";

if($page<>$totalpage)

$out .= " ";

return $out;

}

php 採集常用函式 PHP常用採集函式

獲取所有鏈結內容和位址function getallurl code 獲取所有的位址 function getimgsrc code else fnum if fnum fnum 0 return fnum 去除html標記 function text2html txt isu r n txt re...

PHP常用函式

很有用的一些函式,你可以作為原始碼儲存,然後以後避免重複編寫。檔案讀取函式 檔案讀取函式 function php read file name fclose fd return buf 檔案寫入函式 檔案寫入函式 function php write file name,data,method w...

PHP常用函式

一,字串函式 1,stringaddslashes string str 內容說明 返回字串,該字串為了資料庫查詢語句等的需要在某些字元前加上了反斜線。這些字元是單引號 雙引號 反斜線 與 nul null字元 乙個使用addslashes 的例子是當你要往資料庫中輸入資料時。例如,將名字 o re...