php echo和反斜杠

时间:2016-09-20 00:28:00

标签: php echo

对于我的生活,我不能让这个工作......

if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<a href=\"concert.php?id=. $row["id"] .\">. $row["date"] .</a>"
"<br>";
}

这是错误......

  

语法错误,意外&#39;&#34;&#39;,期待标识符(T_STRING)或   变量(T_VARIABLE)或数字(T_NUM_STRING)

我相信你只需将转义添加到html&#34;?

1 个答案:

答案 0 :(得分:1)

你错过了一些收盘和开盘报价。用单引号替换其中一些双引号也将不再需要那些反斜杠。

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo '<a href="concert.php?id=' . $row["id"] . '">' . $row["date"] . '</a><br>';
    }