iT邦幫忙

DAY 29
0

網頁程式自學亂亂來系列 第 29

主機php5.3到5.4升級之後--addslashes的影響 (更正篇)Magic Quotes

之前遇到網站主機從php5.2升級到php5.3的時候

我誤以為是addslashes()的問題

後來經過大神提點

問題是出在Magic Quotes上面,

於是搜尋了有關Magic Quotes的相關設定,

有以下幾種:

magic_quotes_gpc :

GPC分別代表Get/Post/Cookie.

所有來自於這三種來源的字串會被加上反斜線

magic_quotes_run-time :

將所有來自外部的資料加上引號

magic_quotes_sybase :

在前兩項環境變數開啟的狀態下, 字元 ‘ 會變成 ” 而非 \’

以前我以為要開啓Magic Quotes設定才可以使用addslashes(),

但我搞錯了,應該是要解讀成:

Magic Quotes就是把從外部輸入的字串自動套用addslashes()

另外在php group網站也有對於Magic Quotes做說明:

http://php.net/manual/en/function.addslashes.php

不要再套用過Magic Quotes的字串再用一次addslashes,如下:

The PHP directive magic_quotes_gpc was on by default before PHP 5.4, and it essentially ran addslashes() on all GET, POST, and COOKIE data. Do not use addslashes() on strings that have already been escaped withmagic_quotes_gpc as you'll then do double escaping. The function get_magic_quotes_gpc() may come in handy for checking this.


上一篇
自適應下拉式選單 -- CSS
下一篇
要讓正規表示式跑的順暢的函數 & magic_quotes在php5.4就被拿掉了的解決方法--php
系列文
網頁程式自學亂亂來30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言