php 在数组问题中转义撇号
我对下面的数组有一个问题,其中第一个数组(应该是 Alpe d'Huez)没有逃逸/被发现。
我是否错误地转义了撇号?
<?php
$images = array (
'Alpe D\'Huez' => 'images/flags/small/france_sm.jpg',
'Le Corbier' => 'images/flags/small/france_sm.jpg',
'Les Deux Alpes' => 'images/flags/small/france_sm.jpg'
);
if (isset($images[$this->item->title])) {
?>
<?php } ?>
I have an issue with the below array, where the 1st one (should be Alpe d'Huez) is not escaping/being found.
Am I escaping the apostrophe wrong?
<?php
$images = array (
'Alpe D\'Huez' => 'images/flags/small/france_sm.jpg',
'Le Corbier' => 'images/flags/small/france_sm.jpg',
'Les Deux Alpes' => 'images/flags/small/france_sm.jpg'
);
if (isset($images[$this->item->title])) {
?>
<?php } ?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
就这样完美的逃脱了。
也许问题在于您所比较的价值。尝试 'Alpe D\\'Huez' 看看您的值中的撇号是否是双转义的,或者尝试其他撇号类型,例如 ` 或 ´
That's perfectly escaped like that.
Maybe the problem is with the value that you are comparing against. Try 'Alpe D\\'Huez' to see if in your value the apostrophe is double-escaped or try other apostrophe types like ` or ´
正如巴迪尔所说,它逃脱得很好。我注意到你的问题说“Alpe d'Huez”(小写d),但你的数组说“Alpe D'Huez”(大写d)。它区分大小写 - 这可能是问题所在吗?
As bardiir says, it's escaped just fine. I note that your question says "Alpe d'Huez" (lower case d), but your array says "Alpe D'Huez" (upper case d). It's case sensitive - could that be the issue?