2010-08-25 93 views

回答

3

gpc magic_quotes_gpc代表GET,POST,COOKIE。因此,$_GET,$_POST$_COOKIE中的所有內容都已被轉義。如果啓用了magic_quotes_gpc,則應該在這些數組中的變量上運行反斜槓。

記住要在查詢中的變量運行mysql_real_escape_string()(除了準備好的發言)

magic_quotes的已過時,建議禁用它並使用mysql_real_escape_string()(MySQL的)逃跑的變量。把下面的.htaccess文件禁用magic_quotes_gpc的:

php_flag magic_quotes_gpc off 
php_flag magic_quotes_runtime off 
0

不是「仍然」但是這時候你會需要這個功能的唯一案例。

在包含在所有腳本中的配置文件中。從所有GPC數據中剝離斜線。

0

非常好的ptactice是mysql_real_escape_string(); 我建議你關閉magic_quotes。在PHP 6中,魔術引號將關閉。 如果您的主機不允許您更改此選項,您可以使用下一個功能:

function stripslashes_deep($value) { 
    $value = is_array($value) ? 
       array_map('stripslashes_deep', $value) : 
       stripslashes($value); 

    return $value; 
} 

if((function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()) || (ini_get('magic_quotes_sybase') && (strtolower(ini_get('magic_quotes_sybase'))!="off"))){ 
    stripslashes_deep($_GET); 
    stripslashes_deep($_POST); 
    stripslashes_deep($_COOKIE); 
}