Home  >  Article  >  Backend Development  >  php单引号中字符串的转义("")

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

WBOY
WBOYOriginal
2016-06-23 13:51:221431browse

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

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

aaa\nb
aaa\nb
aaa'b

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

Statement:
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
Previous article:如何避免php执行超时?Next article:新手2