代碼擴充擷取遠程主機socket資訊*/function getpeername(){ $remote_ip=$remote_port=0; //定義ip socket_getpeername($this->fd,$remote_ip,$remote_port); //返回主機資訊 return
函數原型:resource stream_context_create ([ array $options [, array $params ]] )看個執行個體//定義options數組$opts=array( 'http'=>array ( 'method'=>"get", 'header'=>"accept-language: enrn"
文法opendir(path,context)*/$d=dir("c:windows"); //開啟目錄,並賦值給變數echo "handle:".$d->handle."n"; //輸出目錄的handel屬性echo "&
$fp=fopen("test.txt","r");//以唯讀方式開啟檔案,將檔案指標指向檔案頭$fp=fopen("test.txt","r+");//以讀寫方式開啟檔案,將檔案指標指向檔案頭$fp=fopen("test.txt","w");//寫入方式開啟,將檔案指標指向檔案頭並將檔案大小截為零。如果檔案不存在則嘗試建立$fp=fopen("test.txt&q
$file="test.txt"; //定義檔案echo fileowner($file); //擷取檔案所有者/*fileowner() 函數返迴文件的所有者。若成功,則返迴文件所有的使用者 id。若失敗,則返回 false。使用者 id
$temp[0]="abc";$temp[1]=123;$temp[2]="us.";$temp[3]=5;$temp[4]=58;$temp[5]="cs";//以上代碼定義一個數組,其中既有數字也有字串echo "數組temp的內容為:";echo "<p>";//通過迴圈輸出數組內容for($i=0;$i<count($temp);$i++) { echo
echo getcwd()."n"; //取得當前工作目錄echo "<br>";chdir('08'); //改變工作目錄echo getcwd() .
數 format 是轉換的格式,以百分比符號 ("%") 開始到轉換字元結束。下面的可能的 format 值:%% - 返回百分比符號 %b - 位元 %c - 依照 ascii 值的字元 %d - 帶符號十進位數 %e - 可續計數法(比如 1.5e+3) %u - 無符號十進位數 %f - 浮點數(local settings aware) %f - 浮點數(not local settings aware) %o - 八位元 %s - 字串 %x -
strpos() 函數返回字串在另一個字串中第一次出現的位置。如果沒有找到該字串,則返回 false。文法strpos(string,find,start)*/$str="hello
substr_compare() 函數從指定的開始長度比較兩個字串。該函數返回:0 - 如果兩字串相等 <0 - 如果 string1 (從開始位置)小於 string2 >0 - 如果 string1 (從開始位置)大於 string2 文法substr_compare(string1,string2,startpos,length,case)*/$str1="hello
*/$hash_list=hash_algos(); //返回註冊的hash規則列表print_r($hash_list); //顯示結果/*建立檔案以計算雜湊值*/file_put_contents('example.txt', 'the quick brown fox jumped over
similar_text() Function Compute兩個字串的匹配字元的數目。該函數也可以計算兩個字串的相似性(以百分比計)。文法similar_text(string1,string2,percent)注釋:levenshtein() 函數比 similar_text() 函數更快。不過,similar_text() 函數通過更少的必需修改次數提供更精確的結果。下面看執行個體*/$str1="hello
parse_str() 函數把查詢字串解析到變數中。文法parse_str(string,array)注釋:如果未設定 array 參數,由該函數設定的變數將覆蓋已由同名變數。*/parse_str("id=23&name=john%20adams");echo $id."<br />";echo
*/$str="hello world"; //定義字串$result=str_word_count($str); //尋找單詞個數echo $result; &
$crud = array('中國|||我國|||大地', 'kelon|||lerke|||sb', 'sesscxx');$crud = join('|',$crud);$crud = str_replace('|||', '|', $crud);$pat = "/({$crud})/i";$txt = '我知道中國你是sdfex誰!!';preg_match/*_all*/($pat, $txt, $matches);var_dump($matches);/
convert_uudecode() 函數對 uuencode 編碼的字串進行解碼。文法convert_uudecode(string)*/$str=",2&5l;&/@=v]r;&0a `"; //定義uuencode編碼字串$result=convert_uudecode($str);
文法printf(format,arg1,arg2,arg++)參數 描述 format 必需。規定字串以及如何格式化其中的變數。 arg1 必需。規定插到格式化字串中第一個 % 符號處的參數。 arg2 可選。規定插到格式化字串中第二個 % 符號處的參數。 arg++ 可選。規定插到格式化字串中第三、四等等 % 符號處的參數。說明arg1, arg2, ++ 等參數將插入到主字串中的百分比符號 (%) 符號處。該函數是逐步執行的。在第一個 % 符號中,插入 arg1,在第二個 %
//參數'a..z'界定所有大小寫字母均被轉義echo addcslashes('foo[ ]','a..z'); //輸出:foo[ ]//$str="is your name o'reilly?"; //定義字串,其中包括需要轉義的字元echo
定義和用法chop() 函數從字串的末端開始刪除空白字元或其他預定義字元。該函數的 rtrim() 函數的別名。文法chop(string,charlist)*/$str="i'm a teacher
對數組排序usort() 函數使用使用者自訂的函數對數組排序。*/function cmp($a, $b) //使用者自訂回呼函數{ if($a==$b) //如果兩個參數相等 { return