在URL中使用双引号 [英] Using Double-Quotation Marks in a URL

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

问题描述

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



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

预先感谢,



John

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


解决方案

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

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

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


unreserved = ALPHA / DIGIT /noreferrer> RFC3986 ,它定义了安全或' - /。/_/〜


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 href="http://www...com/.../comments/index.php?submission='.$row["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:

unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"

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

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆