php 在数组问题中转义撇号

发布于 2024-12-28 11:20:26 字数 394 浏览 2 评论 0原文

我对下面的数组有一个问题,其中第一个数组(应该是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时间海 2025-01-04 11:20:26

就这样完美的逃脱了。

也许问题在于您所比较的价值。尝试 '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 ´

深海夜未眠 2025-01-04 11:20:26

正如巴迪尔所说,它逃脱得很好。我注意到你的问题说“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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文