mysql
  • php
  • 2010-09-14 90 views 0 likes 
    0

    以下鏈接給我錯誤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>'"); 
    

    任何想法如何解決它?

    回答

    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; 
    
    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,它顯然不是。

    1
    1. 如果「評論連接」是錨標記的文本,它應是雙引號中。但是你已經把它放在雙引號之外,以這種方式解釋爲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>";

    相關問題