php单引号中字符串的转义("")

WBOY
Release: 2016-06-23 13:51:22
Original
1430 people have browsed it

我们知道php中的单引号不会对其中的字符串变量进行替换处理,只有双引号才能进行替换处理。那么单引号会对转义处理吗?

<?php function dump($str){		echo "<pre class="brush:php;toolbar:false">";		print_r($str);		echo "
Copy after login
"; } $str = 'aaa\nb'; $str2 = 'aaa\\nb'; $str3 = 'aaa\'b'; dump ($str); dump ($str2); dump ($str3);
结果为:

aaa\nb
Copy after login
Copy after login
aaa\nb
Copy after login
Copy after login
aaa'b
Copy after login

从上面可以看出,php的单引号只对反斜线和单引号进行转义,其他的不会进行转义。

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