嵌入式PHP if语句无法正常工作

时间:2015-06-11 15:43:40

标签: php html

这可能是我忽略的一个简单原因,但我的第二个if语句,一个条件为sizeof($ duplicate)> 0,运行不正常。尽管我已经验证$ duplicate的大小实际上是0,并且段落标签下没有显示列表,但仍然显示html块。我错过了什么吗?

<html>
<head>
</head>
<body>
    <?php echo (sizeof($duplicate)); ?>
    <?php if(sizeof($not_exist > 0)) : ?>
        <p>The following companies were not updated because their Company Name did not exist in database: </p>
        <ul>
            <?php foreach($not_exist as $entry) {
                echo "<li>Company Name: " . $entry . "</li>";
            }
            ?>
        </ul>
    <?php endif; ?>
    <?php if(sizeof($duplicate > 0)) : ?>
        <p>The following companies had more than 1 entry under the same Company Name in database:</p>
        <ul>
            <?php foreach($duplicate as $entry) {
                echo "<li>Company Name: " . $entry . "</li>";
            }
            ?>
        </ul>
    <?php endif; ?>
    <?php if(sizeof($failed > 0)) : ?>
        <p>The following companies were not updated because the new Display Name already exists in QuickBooks:</p>
        <ul>
            <?php foreach($failed as $entry) {
                echo "<li>Company Name: " . $entry . "</li>";
            }
            ?>
        </ul>
    <?php endif; ?>
</body>

谢谢!

1 个答案:

答案 0 :(得分:3)

<?php if(sizeof($duplicate )>0) : ?>