static 宣告就宣告,速度提升近 4 倍。$row['id'] 比 $row[id] 快 7 倍。echo 多參數輸出優於字串連接,且快於 print。foreach。unset() 大陣列釋放記憶體。__get、__set、__autoload 魔術方法。require_once() 開銷大,能用 require 就用。include 使用絕對路徑,減少路徑解析。$_SERVER['REQUEST_TIME'] 而非 time()。strpos vs preg_match)。strtr 效能是 str_replace 的 4 倍。switch-case 優於多層 if-elseif。@ 抑制錯誤極其低效,嚴禁濫用。mod_deflate 壓縮傳輸。isset($str{5}) 替代 strlen($str) < 5,語言結構更快。++$i 比 $i++ 快(少一條 opcode)。mod_zip 即時壓縮傳輸量降 80%。file_get_contents 替代 fopen/fread 系列,效率高得多。INSERT/UPDATE 頻率。foreach 效率優於 while/for。$i += 1 比 $i = $i + 1 快。unset()。checkdnsrr() 驗證 Email 域名存在性。mysqli_* 函數族。highlight_file() 產生格式化原始碼頁面。error_reporting(0) 防敏感資訊洩露,最佳在 php.ini 關閉。&$var。addslashes() 按需轉義。ip2long()/long2ip() 儲存 IP 為整數,省空間且利查詢。gzcompress()/gzuncompress() 大字串壓縮存入 DB,壓縮率 90%。以上技巧涵蓋語法、記憶體、資料庫、快取、伺服器等層面,實務中請依專案實測套用。