-1

php代码

 echo "<td><a href=?V*".$row['rec_title']."> ". $row['rec_title'] . "</a></td>";

html代码

<a href=?V*Venison with Frumenty(British)> Venison with Frumenty(British)</td>

但是当我点击 -> Venison with frumenty (british) 链接是生成半链接示例 http://ex.com/?Vension

我想要像这样的完整链接 http://ex.com/?Venison with Frumenty(British)

如何解决这个问题请帮我解决这个问题

4

2 回答 2

0

您应该使用 urlencode ( http://php.net/urlencode ) 来显示这样的链接:

 echo "<td><a href=\"?V*".urlencode($row['rec_title'])."\"> ". $row['rec_title'] . "</a></td>";

urlencode 将替换%20为空格的两位十六进制表示的空格。您应该养成urlencode在这些情况下始终使用的习惯。

此外,正如 Devang 和 Class 所说 - 不要忘记您的属性值周围的引号。而不是<a href=something></a><a href="something"></a>

于 2013-03-09T08:17:48.570 回答
0

您可以使用urlencode()来实现相同的功能。

echo "<td><a href=?V*".urlencode($row['rec_title'])."> ". $row['rec_title'] . "</a></td>";
于 2013-03-09T08:18:12.767 回答