以前我寫php的沒有多想這個魔術引用的問題
最近不是挺忙就研究了一下,沒有想到設置魔術引用的還有兩個了呢
magic_quotes_gpc是設置Get、Post、Cookies的,此設置爲on是客戶端提交過來的數據會自動轉義的,這個轉義是用來操作數據庫時使用的,如果你用來顯示的化還是要去掉這轉義的,不然顯示就多個反斜槓了
magic_quotes_gpc是不能在php運行中設置的。
magic_quotes_runtime的設定值將會影響從文件中讀取的數據或從數據庫查詢得到的數據
這個我今天還特意的測試了一下呢代碼如下
echo get_magic_quotes_runtime().'<br>';
echo readfile("test5.php");
set_magic_quotes_runtime(true);
echo get_magic_quotes_runtime().'<br>';
echo readfile("test5.php")
test5.php文件內容如下 'jsdflsf//ffff'
顯示內容如下
0
'jsdflsf//ffff'
171
'jsdflsf//ffff' 17
靠竟然沒有什麼用啊,真是奇怪了。我代碼調整了好幾次也沒有什麼變化啊。
沒有想到什麼好的辦法,那就換個讀取文件的方法了
又測試瞭如下
echo get_magic_quotes_runtime().'<br>';
echo file_get_contents("test5.php");
set_magic_quotes_runtime(true);
echo get_magic_quotes_runtime().'<br>';
echo file_get_contents("test5.php")
顯示內容如下
0
'jsdflsf//ffff'
1
/'jsdflsf////ffff/'
總算是有用了,看來是這個set_magic_quotes_runtime對readfile是沒有用的