Home > Backend Development > PHP Tutorial > PHP转义字符有关问题

PHP转义字符有关问题

WBOY
Release: 2016-06-13 12:30:34
Original
863 people have browsed it

PHP转义字符问题
在网上,搜到了很多文章,上面都说:
以单引号为定界符的php字串,支持2个转义:\\, \' 
以双引号为定界符的php字串,支持8个转义:\\, \", \r, \n, \t, \$, \[0-7]{1,3}, \x[0-9A-Fa-f]{1,2} 
但实际操作中,并不是这样子,对单引号和双引号,addshlashes()都会进行转义,以下例为证,有人意见相左吗?
以下是测试结果:
$single_quote_str = '\'单引号\'内之 "双引号" 测试.';
$double_quote_str = "\"双引号\"内之'单引号'测试.";

单引号测试:
原始输出字串='单引号'内之 "双引号" 测试. 
转义字串=\'单引号\'内之 \"双引号\" 测试. 
还原字串='单引号'内之 "双引号" 测试. 
双引号测试:
原始输出字串="双引号"内之'单引号'测试. 
转义字串=\"双引号\"内之\'单引号\'测试. 
还原字串="双引号"内之'单引号'测试. 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template