Php 刀片模板化没有错误消息

Php 刀片模板化没有错误消息,php,laravel,blade,Php,Laravel,Blade,我有一个刀片模板,其中包含一些PHP逻辑,如下所示: <?php $prevCatCode = null; $catStyleCode = null; $isSameCatCode = false; ?> <h2>Products</h2> <table class="productsTable" style="width:100%"> <thead> <tr>

我有一个刀片模板,其中包含一些PHP逻辑,如下所示:

<?php
    $prevCatCode = null;
    $catStyleCode = null;
    $isSameCatCode = false;
?>

<h2>Products</h2>
<table class="productsTable" style="width:100%">
    <thead>
        <tr>
            <th>Code</th>
            <th>Qty</th>
            <th>Price</th>
            <th>Total</th>
        </tr>
    </thead>
    <tbody>
        @foreach($draftOrderProducts as $key => $draftOrderProduct)
        <?php 
            $catStyleCode = $draftOrderProduct['cat_style_code'];
            if ($prevCatCode !== null && $prevCatCode == $catStyleCode) {
                $isSameCatCode = true;
            } else {
                $isSameCatCode = false;
            }
            $prevCatCode = $catStyleCode;

            if (!$isSameCatCode || $key == 0) { ?>
                <tr><td colspan="4"><b>{{ $catStyleCode }}</b>  (Retail Price: {{ $draftOrderProduct['retail_price'] }})</td></tr>;
            <?php } ?>

            <tr>
                <td>{{ $draftOrderProduct['code'] }}</td>
                <td>{{ $draftOrderProduct['products_quantity'] }}</td>
                <td>{{ money_format("%(#10n", $draftOrderProduct['products_price']) }} (Retail: {{money_format("%(#10n", $draftOrderProduct['retail_price'])}})</td>
                <td>{{ money_format("%(#10n", $draftOrderProduct['final_price']) }}</td>
            </tr>
        @endforeach
我想知道我是否在这个刀片文件中正确使用了PHP标记。你知道那里怎么了吗


$data被传递到模板,并具有如下数据:$data['draftOrderProducts']=$draftOrderProducts

$draftOrderProducts在哪里定义?实际上再看一遍,foreach不在PHP中,我将$data传递给模板$数据['draftOrderProducts']=$draftOrderProducts;你的观点完全是混乱的。我强烈建议将所有逻辑移到刀片文件之外,并在这里仅使用诸如@foreach、@if、@else等刀片结构。我一定会对此进行研究。然而,你能注意到这里的代码是否有问题吗?