0

我知道我会为此受到很多反对,但是,我似乎真的无法让它发挥作用:

我试图使链接简单地转到(说变量是 blahblah) /listen?v=blahblah 但是,我最终得到 /listen?v="blahblah" 或错误。

这是我尝试过的 php 行的片段:

echo "<a href='/listen?v=$escapedString'>";

echo "<a href='/listen?v=" . $escapedString . "'>";

而且我已经尝试将零件分离到单独的行等上,老实说,我不明白为什么要这样做。

4

2 回答 2

2

Your both lines are correct, so the quotes must be inside the content of the variable, you can trim them like this:

$escapedString = trim($escapedString, '"');

or just do it for the link:

echo "<a href='/listen?v=" . trim($escapedString, '"') . "'>";
于 2012-11-27T12:38:04.680 回答
0

You need your file extension. For example, if it's a PHP file...

echo "<a href='/listen.php?v=$escapedString'>";
于 2012-11-27T12:36:23.630 回答