【问题标题】:Call php function inside <td> [duplicate]在 <td> 中调用 php 函数 [重复]
【发布时间】:2016-12-30 20:47:18
【问题描述】:

我在我的 html 表中调用 php 函数时遇到了困难。

    <table>
        <thead class="table">
        <tr><th>Letter</th><th>Sender</th></tr>
        </thead>
        <tbody>
        <?php require_once 'assets/userFunctions.php';
        foreach ($myCvs as $cv){
            echo "<tr>
            <td>{$cv['cv']}</td>
            <td>getUsernameById({$cv['senderid']})</td>
            </tr>";
        }
        ?>
        </tbody>
    </table>

在表格中我只看到getUsernameById(2),例如...

【问题讨论】:

    标签: php html


    【解决方案1】:

    你需要使用连接:

    echo "<tr><td>" . $cv['cv'] . "</td><td>" . getUsernameById($cv['senderid']) . "</td></tr>";
    

    【讨论】:

    • 我要补充一点,这个问题与&lt;td&gt; 无关,而实际上是“在 php 中调用 echo 语句中的函数”。
    猜你喜欢
    • 1970-01-01
    • 2012-12-30
    • 1970-01-01
    • 2018-04-22
    • 1970-01-01
    • 1970-01-01
    • 2014-09-11
    • 2012-06-11
    • 2012-11-24
    相关资源
    最近更新 更多