首页 > 解决方案 > 如何在包含在 php 文件中的单引号内的 html 中编写 php 代码?

问题描述

$body = '<div data-shordcode="[woo_mb_items]"><div class="ywot_order_details top"><br></div>    <h2>Order #2717</h2>

                <table class="email_builder_table_items" cellspacing="0" cellpadding="6" style="width: 100% !important;" border="1" width="100%">
                    <thead>
                    <tr>
                        <th class="td" scope="col" style="text-align:left;">Product</th>
                        <th class="td" scope="col" style="text-align:left;">Quantity</th>
                        <th class="td" scope="col" style="text-align:left;">Price</th>
                    </tr>
                    </thead>
                    <tbody>
                         <tr class="order_item">
                *php code*
                            <td class="td" style="text-align:left; vertical-align:middle;word-wrap:break-word;"><div style="margin-bottom: 5px"><img src="'.$thumbnail.$_SESSION['img_url'].'" alt="Product image" height="32" width="32" style="vertical-align:middle; margin-right: 10px;"></div>'. $_SESSION['product'] .'</td>
                            <td class="td" style="text-align:left; vertical-align:middle;">'. $_SESSION['quantity'] .'</td>
                            <td class="td" style="text-align:left; vertical-align:middle;"><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">$</span>'. $_SESSION['total'] .'</span> <small class="woocommerce-Price-taxLabel tax_label">(ex. tax)</small></td>
                        </tr>
                        </tr>
                    </tbody>
                    <tfoot>
                        <tr>
                                <th class="td" scope="row" colspan="2" style="text-align:left; border-top-width: 1px">Subtotal:</th>
                                <td class="td" style="text-align:left; border-top-width: 1px;"><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">$</span>'. $_SESSION['subtotal'] .'</span> <small class="tax_label">(ex. tax)</small></td>
                                </tr><tr>
                                <th class="td" scope="row" colspan="2" style="text-align:left; ">Shipping:</th>
                                <td class="td" style="text-align:left; ">'. $_SESSION['shipping'] .'</td>
                                </tr><tr>
                                <th class="td" scope="row" colspan="2" style="text-align:left; ">Payment method:</th>
                                <td class="td" style="text-align:left; ">'. $_SESSION['payment'] .'</td>
                                </tr><tr>
                                <th class="td" scope="row" colspan="2" style="text-align:left; ">Total:</th>
                                <td class="td" style="text-align:left; "><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">$</span>'. $_SESSION['total'] .'</span></td>
                        </tr>
                    </tfoot>
                </table>
        </div>';

我想在我指定php 代码的地方编写 php 循环,以便那里的表 data() 将重复我的时间作为给定数组中的结果数。我也尝试过php 标签连接,但这些似乎都不起作用。有没有办法做到这一点?...任何建议将不胜感激..

标签: phphtml

解决方案


推荐阅读