【问题标题】:Echo and echo in PHPPHP中的回声和回声
【发布时间】:2023-12-17 18:22:02
【问题描述】:

如何在php中回显下面的代码?

<a href="cust_room/assign_room.php?cust_id=<?php echo $row_customer['cust_id']; ?>">Assign Room</a>

我确实尝试过,但出错了。

echo "<a href=\"cust_room/assign_room.php?cust_id=<?php echo $row_customer['cust_id']; ?>\">Assign Room</a>";

【问题讨论】:

    标签: php


    【解决方案1】:

    你不能在 &lt;?php 中使用 &lt;?php

    试试下面的代码:

    echo "<a href=\"cust_room/assign_room.php?cust_id={$row_customer['cust_id']}\">Assign Room</a>";
    

    代替:

    echo "<a href=\"cust_room/assign_room.php?cust_id=<?php echo $row_customer['cust_id']; ?>\">Assign Room</a>";
    

    【讨论】:

    • @JohnnyJ3T 欢迎使用 *。如果此答案有帮助,请接受答案。
    【解决方案2】:

    尝试原因:echo 在另一个回声中!使用 concat 回显 $row_customer['cust_id'] 中的值

    <?php echo "<a href=\"cust_room/assign_room.php?cust_id=".$row_customer['cust_id'] ."\">Assign Room</a>"; ?>
    

    【讨论】: