set_magic_quotes_runtime() 自 PHP 5.3 起**棄用**,PHP 7.0 **完全移除**。舊代碼調用會拋出 Deprecated 或 Fatal error。
<?php
// 舊代碼
set_magic_quotes_runtime(0);
// 替代:運行時設置 ini
ini_set('magic_quotes_runtime', '0');
// 或 php.ini 永久生效
; magic_quotes_runtime = Off
GET/POST/COOKIE 數據轉義引號 (' → \', " → \", \ → \\, NULL → \0)。grep -r "magic_quotes" --include="*.php" .set_magic_quotes_runtime 為 ini_set('magic_quotes_runtime', 0) 或直接刪除(PHP 5.4+ 無效)。get_magic_quotes_gpc() 判斷邏輯,現代代碼**直接假設關閉**處理。<?php
// 1. 數據庫:使用預處理語句 (PDO/MySQLi)
$stmt = $pdo->prepare("SELECT * FROM users WHERE email = ?");
$stmt->execute([$_POST['email']]); // 無需手動轉義
// 2. HTML 輸出:htmlspecialchars
echo htmlspecialchars($userInput, ENT_QUOTES, 'UTF-8');
// 3. Shell 命令:escapeshellarg/escapeshellcmd
$cmd = 'ls ' . escapeshellarg($filename);
// 4. JSON:json_encode 自動處理
echo json_encode($data);
// 5. 正則:preg_quote
$pattern = '/' . preg_quote($keyword, '/') . '/';
?>
set_magic_quotes_runtime 調用。get_magic_quotes_gpc 相關判斷分支。addslashes/stripslashes。htmlspecialchars (HTML) / json_encode (API)。