本文介绍了在URL中使用双引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的链接工作正常,除非变量 $ row [title] 包含一个双引号()。在这种情况下,引号后的所有内容在链接中被省略。



我怎样才能让链接包含双引号之后的所有内容?

预先感谢,



John

  echo'< td class =sitename2>< a href =http://www...com/.../comments/index.php?submission ='。$ row [title]。'>' 。$ row [countComments]。'COMMENTS< / a>< / td>'; 


解决方案

对于可能需要包含的网址部分,始终使用任何不寻常的......

  echo'< td class =sitename2>'。
'< ; a href =http://www...com/.../comments/index.php?submission ='。
urlencode($ row [title])。
'>'。
$ row [countComments]。'COMMENTS< / a>< / td>';

如果您想进入标准,请参阅

urlencode确保您想要包含在URL中的值服从这些标准

The link below works fine unless the variable $row["title"] contains a double-quotation mark ("). In that case, everything after the quotation marks is omitted in the link.

How can I make the link include everything after a double-quotation mark?

Thanks in advance,

John

echo '<td class="sitename2"><a target="_blank" lml-data-x="https://www.lmlphp.com/r?x=CtQ9yf-Vsi2i2jl6sxIVzHu6sNlVPMbdzEK62toVCEwY4La6ye7ODiISPxS3yiI3zMlb5tOwp8"title"].'">'.$row["countComments"].' COMMENTS</a></td>';

Always use urlencode for parts of a URL which might need to contain anything unusual....

echo '<td class="sitename2">'.
  '<a href="http://www...com/.../comments/index.php?submission='.
  urlencode($row["title"]).
  '">'.
  $row["countComments"].' COMMENTS</a></td>';

If you want to get into the standards, refer to RFC3986 which defines the safe, or 'unreserved' character as follows:

urlencode makes sure that a value you want to include in a URL obeys these standards

这篇关于在URL中使用双引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 10:09
查看更多