廣告廣告
  加入我的最愛 設為首頁 風格修改
首頁 首尾
 手機版   訂閱   地圖  簡體 
您是第 2283 個閱讀者
 
發表文章 發表投票 回覆文章
  可列印版   加為IE收藏   收藏主題   上一主題 | 下一主題   
gavintom 手機
數位造型
個人文章 個人相簿 個人日記 個人地圖
小人物
級別: 小人物 該用戶目前不上站
推文 x0 鮮花 x5
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片
推文 x0
[PHP][討論] addslashes 這個function何時該用?
小弟想請教大大們

addslashes()這個東西何時該用呢??

例如: 若從page1輸入東西(如:許功蓋等..特殊字) 到page2要存入mysql時
    這個時候需要加這個function嗎?

還是說有什麼情形下要用到它的呢??


獻花 x0 回到頂端 [樓 主] From:台灣數位聯合 | Posted:2005-07-16 09:24 |
andyz 手機 會員卡
數位造型
個人文章 個人相簿 個人日記 個人地圖
社區建設獎
頭銜:惡靈退散 o(╬ ̄皿 ̄)=○ &nb ..惡靈退散 o(╬ ̄皿 ̄)=○ &nb ..
分類版主
級別: 分類版主 該用戶目前不上站
版區: 塑膠模型, 電腦資訊
推文 x55 鮮花 x168
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片

addslashes
(PHP 3, PHP 4 , PHP 5)

addslashes -- Quote string with slashes

Description
string addslashes ( string str )


Returns a string with backslashes before characters that need to be quoted in database queries etc. These characters are single quote ('), double quote ("), backslash (\) and NUL (the NULL byte).

An example use of addslashes() is when you're entering data into a database. For example, to insert the name O'reilly into a database, you will need to escape it. Most databases do this with a \ which would mean O\'reilly. This would only be to get the data into the database, the extra \ will not be inserted. Having the PHP directive magic_quotes_sybase set to on will mean ' is instead escaped with another '.

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

範例 1. An addslashes() example
<?php
$str = "Is your name O'reilly?";

// Outputs: Is your name O\'reilly?
echo addslashes($str);
?>


回文原則(以下只適用在我的管理區)
1.我不回太白目的問題
2.還有娘家文
3.看不懂得也是
4.我很懶得把你的問題(也就是文字敘述)想成我要看到的畫面(也就是螢幕上出現的畫面)。純文字敘述者,看不懂在說啥就不回。想要解答就先下點功夫,來個圖文並茂的文章吧。
5.想到再打

何謂白目問題
1.看不懂英文的,要求翻譯
2.沒經過爬文就問
3.給個問題(題目)就要求解答。例如:請問XXX怎麼寫。自己的CODE都沒有貼上來就要求別人幫你寫,不如你的作業我幫你作、你的書我幫你讀好了
4.想到再打
獻花 x0 回到頂端 [1 樓] From:台灣數位聯合 | Posted:2005-07-16 11:36 |

首頁  發表文章 發表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.011754 second(s),query:16 Gzip disabled
本站由 瀛睿律師事務所 擔任常年法律顧問 | 免責聲明 | 本網站已依台灣網站內容分級規定處理 | 連絡我們 | 訪客留言