惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Hacker News
The Hacker News
Google Online Security Blog
Google Online Security Blog
K
Kaspersky official blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
Schneier on Security
C
Cybersecurity and Infrastructure Security Agency CISA
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News - Newest:
Hacker News - Newest: "LLM"
Cisco Talos Blog
Cisco Talos Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Cyberwarzone
Cyberwarzone
L
LINUX DO - 最新话题
PCI Perspectives
PCI Perspectives
酷 壳 – CoolShell
酷 壳 – CoolShell
云风的 BLOG
云风的 BLOG
N
News and Events Feed by Topic
N
News and Events Feed by Topic
V
Vulnerabilities – Threatpost
T
Troy Hunt's Blog
GbyAI
GbyAI
C
CERT Recently Published Vulnerability Notes
G
Google Developers Blog
Microsoft Azure Blog
Microsoft Azure Blog
量子位
Scott Helme
Scott Helme
月光博客
月光博客
Attack and Defense Labs
Attack and Defense Labs
aimingoo的专栏
aimingoo的专栏
博客园 - 聂微东
Project Zero
Project Zero
G
GRAHAM CLULEY
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
小众软件
小众软件
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
V2EX
Stack Overflow Blog
Stack Overflow Blog
爱范儿
爱范儿
S
Security @ Cisco Blogs
The Last Watchdog
The Last Watchdog
MongoDB | Blog
MongoDB | Blog
H
Hacker News: Front Page
Latest news
Latest news
P
Proofpoint News Feed

博客园 - wasd

pear安装步骤 linux定时任务的设置 C语言字符串拆分,打开关闭文件 - wasd - 博客园 js-tips 用optgroup 禁用select中的option方法 - wasd - 博客园 DB2常用语句记录 Linux 强制卸载软件 - wasd - 博客园 Setup locally visual host - wasd B:X星球的身份证系统 B:有道搜索框 B:有道饭团 A:另类的异或 C:Sibonacci - wasd - 博客园 CakePHP支持DB2 PHP 的变量 - wasd - 博客园 DB2 SQLSTATE 消息异常 JDBC中Preparedstatement使用小结 及JDBC插入数据后获得Last insert ID 并行计算简介 PB3编译adobe的例子photoviewer时错误处理
addslashes、get_magic_quotes_gpc函数、stripslashes函数(转来记录一下) - wasd - 博客园
wasd · 2010-10-18 · via 博客园 - wasd

addslashes -- 使用反斜线引用字符串

描述

string addslashes ( string str)

返回字符串,该字符串为了数据库查询语句等的需要在某些字符前加上了反斜线。这些字符是单引号(')、双引号(")、反斜线(\)与 NUL(NULL 字符)。

一个使用 addslashes() 的例子是当你要往数据库中输入数据时。例如,将名字 O'reilly 插入到数据库中,这就需要对其进行转义。大多数据库使用 \ 作为转义符:O\'reilly。这样可以将数据放入数据库中,而不会插入额外的 \。当 PHP 指令 magic_quotes_sybase 被设置成 on 时,意味着插入 ' 时将使用 ' 进行转义。

默认情况下,PHP 指令为 on,它主要是对所有的 GET、POST 和 COOKIE 数据自动运行 addslashes()。不要对已经被 转义过的字符串使用 addslashes(),因为这样会导致双层转义。遇到这种情况时可以使用函数进行检测。

例子 1. addslashes() 示例

<?php
$str
= "Is your name O'reilly?"
;// 输出:Is your name O\'reilly?
echo addslashes($str
);
?>

本函数取得 PHP 环境配置的变量 magic_quotes_gpc (GPC, Get/Post/Cookie) 值。返回 0 表示关闭本功能;返回 1 表示本功能打开。当 magic_quotes_gpc 打开时,所有的 ' (单引号), " (双引号), \ (反斜线) and 空字符会自动转为含有反斜线的溢出字符。

Definition and Usage
定义和用法

The stripslashes() function removes backslashes added by the addslashes() function.
stripslashes()函数的作用是:将用addslashes()函数处理后的字符串返回原样。

Tips and Notes
提示

Tip: This function can be used to clean up data retrieved from a database or from an HTML form.
提示:这个函数可以用来清除从数据库中或HTML表格中获取的数据。


Example
案例

<?php
echo stripslashes("Who\'s Kai Jim?");
?>

The output of the code above will be:
上述代码将输出下面的结果: