奇怪的preg_quote行为 [英] strange preg_quote behavior
本文介绍了奇怪的preg_quote行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个代码
<?php
$a = "\\u0000";
$b = preg_quote($a);
echo "<br />my own: ".$a;
echo "<br />with preg_quote:". $b;
?>
如何可能一个 \
字符消失从我的 $ a
变量?
How is possible that one \
character vanished from my $a
variable?
我认为这是非常开始的行为/问题,但我真的很失落转义字符
I think it's very begginer behavior/question but I'm really lost about these escape characters.
免责声明:我不是PHP中的开始
Disclaimer: I'm not begginer in PHP
推荐答案
p>因为 \
转义下一个,因为每个 \
需要转义。
because \
escapes the next one, as every \
needs to be escaped.
与单个\它转义下一个字符巫婆是你,但\u不是一个char代码,所以它显示为一个简单的字符
with a single \ it escapes the next character witch is u, but \u isn't a char code so it is displayed like a simple character
这篇关于奇怪的preg_quote行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文