尝试显示超链接时解析错误

时间:2010-09-14 08:51:52

标签: mysql php

以下链接给出了错误Parse error: syntax error, unexpected T_STRING

$link1 = "<a href='http://www.domain.com/path/comments/index.php?submission=".urlencode($submission)."&submissionid=".urlencode($submissionid)."&url=".urlencode($url)."&countcomments=".urlencode($countcomments)."&submittor=".urlencode($submittor)."&submissiondate=".urlencode($submissiondate)."&dispurl=".urlencode($dispurl)."'>'".Comment Link."'</a>'");

知道怎么解决吗?

3 个答案:

答案 0 :(得分:1)

像这样:

$link1 = "<a href='http://www.domain.com/path/comments/index.php?submission=".urlencode($submission)."&submissionid=".urlencode($submissionid)."&url=".urlencode($url)."&countcomments=".urlencode($countcomments)."&submittor=".urlencode($submittor)."&submissiondate=".urlencode($submissiondate)."&dispurl=".urlencode($dispurl)."'>Comment Link</a>";

通过这样做:

".Comment Link."

PHP认为Comment Linkcode,显然不是。{/ p>

答案 1 :(得分:1)

你有额外的)和不必要的连接,这是正确的版本:

$link1 = "<a href='http://www.domain.com/path/comments/index.php?submission=".urlencode($submission)."&submissionid=".urlencode($submissionid)."&url=".urlencode($url)."&countcomments=".urlencode($countcomments)."&submittor=".urlencode($submittor)."&submissiondate=".urlencode($submissiondate)."&dispurl=".urlencode($dispurl).">Comment Link</a>";

echo $link1;

答案 2 :(得分:1)

  1. 如果“Comment Link”是锚标记的文本,它应该在双引号内。但是你把它放在双引号之外,以便它被解释为PHP代码。

    你做的事情如下:

    $link = "<a href='" . $pageurl . "'>" . Comment Link . "</a>"

    但你应该做的事情如下:

    $link = "<a href='" . $pageurl . "'>Comment Link</a>"

  2. 你最后还有一个额外的。

  3. 所以你的实际代码应该是

    $link1 = "<a href='http://www.domain.com/path/comments/index.php?submission=".urlencode($submission)."&submissionid=".urlencode($submissionid)."&url=".urlencode($url)."&countcomments=".urlencode($countcomments)."&submittor=".urlencode($submittor)."&submissiondate=".urlencode($submissiondate)."&dispurl=".urlencode($dispurl)."'>Comment Link</a>";