萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 程式設計 >  >> 網路程式設計 >> PHP 程式設計

PHP 5 常用函數速查表(分類整理版)

網路上許多所謂「PHP 函數大全」其實並不完整。本文整理 PHP 5 核心函數,按功能分類,方便開發者快速查找。

系統與執行控制

  • sleep()、usleep()、time_nanosleep()、time_sleep_until():延遲執行
  • ignore_user_abort():用戶斷線是否終止腳本
  • exit()、die():輸出訊息並結束腳本
  • eval():執行字串作為 PHP 代碼
  • highlight_file()、highlight_string()、show_source():語法高亮顯示
  • strip_whitespace():移除註解與空白
  • get_browser():取得瀏覽器能力資訊
  • connection_status()、connection_aborted():連線狀態檢查

常數處理

  • define()、defined()、constant()

ZIP 壓縮檔操作

  • zip_open()、zip_read()、zip_close()
  • zip_entry_open()、zip_entry_read()、zip_entry_name()、zip_entry_filesize()、zip_entry_compressedsize()、zip_entry_compressionmethod()、zip_entry_close()

XML 解析器 (SAX 模式)

  • xml_parser_create()、xml_parser_create_ns()、xml_parser_free()
  • xml_parse()、xml_parse_into_struct()
  • 各種 handler 設定:xml_set_element_handler()、xml_set_character_data_handler()、xml_set_default_handler() 等
  • 錯誤處理:xml_get_error_code()、xml_error_string()、xml_get_current_line_number() 等

字串函數(精選常用)

分類函數
大小寫轉換strtolower()、strtoupper()、ucfirst()、ucwords()
修剪與填充trim()、ltrim()、rtrim()、str_pad()
查找與替換strpos()、strrpos()、stripos()、strripos()、strstr()、stristr()、str_replace()、str_ireplace()、substr_replace()
截取與分割substr()、substr_count()、substr_compare()、explode()、implode()、str_split()、strtok()
比較strcmp()、strcasecmp()、strncmp()、strnatcmp()、strnatcasecmp()
編碼與雜湊md5()、md5_file()、sha1()、sha1_file()、crypt()、base64_encode()、base64_decode()、urlencode()、urldecode()
格式化sprintf()、printf()、vsprintf()、vprintf()、number_format()、money_format()
其他strlen()、strrev()、str_shuffle()、str_rot13()、wordwrap()、nl2br()、strip_tags()、addslashes()、stripslashes()、htmlspecialchars()、htmlentities()

陣列函數(精選常用)

  • 建立:array()、range()、array_fill()
  • 鍵值操作:array_keys()、array_values()、array_flip()、array_reverse()
  • 堆疊/佇列:array_push()、array_pop()、array_unshift()、array_shift()
  • 合併與差集:array_merge()、array_diff()、array_intersect()
  • 搜尋與篩選:in_array()、array_search()、array_filter()、array_map()
  • 排序:sort()、rsort()、asort()、arsort()、ksort()、krsort()、usort()
  • 其他:count()、sizeof()、array_unique()、array_chunk()、array_slice()、array_splice()、extract()、compact()

日期時間

  • date()、time()、mktime()、strtotime()、date_default_timezone_set()、DateTime 類別

檔案系統

  • fopen()、fclose()、fread()、fwrite()、file_get_contents()、file_put_contents()、file()、copy()、unlink()、mkdir()、rmdir()、is_readable()、is_writable()、filesize()、filemtime()

更多函數請參考 PHP 官方函數參考。

copyright © 萬盛學電腦網 all rights reserved