php遇到的有用的函式

2021-07-24 12:55:08 字數 928 閱讀 9510

header(『location:』)

chdir()改變目錄

basename(file)當前檔名稱

strpos strrpos stripos strripos

substr()

empty

isset

realpath()獲取絕對路徑

set_exception_handler() 函式

<?php

// 使用者定義的異常處理函式

function

myexception

($exception)

// 設定使用者定義的異常處理函式

set_exception_handler("myexception");

// 丟擲異常

throw

newexception("uncaught exception occurred!");

?>

以上**的輸出類似這樣:

exception: uncaught exception occurred!

(同理還有set_error_handle())

function customerror($errno,$errstr,$errfile,$errline)\r\n";

echo

"**行數:檔案";

echo

"php版本,php_version,"

die();

}

set_error_handle會接管php內建的錯誤處理,也可以在同乙個頁面用restore_error_handle()取消接管

php_eol 換行符 unix下相當於\n windows下相當於\r\n mac下相當於\r

有用的php函式

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

php,幾個有用的函式介紹

strtr 函式轉換字串中 陣列中特定的字元。arr array hello hi world earth echostrtr hello world arr 輸出 hi earththe file put contents writes a string to a file.file put co...

5個有用的php陣列操作函式

1 修改一維陣列裡面某乙個鍵值對的key的名稱 修改陣列裡面某個key的名字 function array change key input,key,replace key 2 刪除一維陣列裡面某個值 刪除陣列裡面的某個值 function array delete input,value 3 刪除...