广告广告
  加入我的最爱 设为首页 风格修改
首页 首尾
 手机版   订阅   地图  繁体 
您是第 2286 个阅读者
 
发表文章 发表投票 回覆文章
  可列印版   加为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.011017 second(s),query:16 Gzip disabled
本站由 瀛睿律师事务所 担任常年法律顾问 | 免责声明 | 本网站已依台湾网站内容分级规定处理 | 连络我们 | 访客留言