Php 如果有,我如何生成此代码?

Php 如果有,我如何生成此代码?,php,html,Php,Html,如果有,我如何生成此代码? 如果“租金”为真,请执行此操作。。。。其他的做错误的一点。我在PHP标签中迷失了方向 <?php if( get_post_meta($post->ID, 'Rental', true) ) { ?> <li style="padding:3px 10px; line-height: 18px; height:34px"><strong><?php _e( 'Rental Potential / Actual

如果有,我如何生成此代码? 如果“租金”为真,请执行此操作。。。。其他的做错误的一点。我在PHP标签中迷失了方向

<?php 
    if( get_post_meta($post->ID, 'Rental', true) ) { 
?>
<li style="padding:3px 10px; line-height: 18px; height:34px"><strong><?php _e( 'Rental Potential / Actual', 'spanglishwebs' ) ?>:</strong> <?php 
    $priceWithoutFormat = get_custom_field('Rental');
    $priceWithFormat = number_format($priceWithoutFormat, 0, ',', '.');
    echo $priceWithFormat; 
?>&euro;/Annual </li>
<?php 
    }
    if( get_post_meta($post->ID, 'Rental', false) ) { 
?>
<li>Rental Potential / Actual: N/A</li>
<?php 
    } 
?>

  • &euro/年度
  • 潜在/实际租金:不适用
  • 
    
  • &欧元/年度
  • 潜在/实际租金:不适用

  • 试试看,如果它能工作,你的代码真的很凌乱…

    我在php标签中迷失了方向。格式化你的代码,你就不会丢失你的代码。现在它完全坏了!我通常认为在开始和结束时放置php标记,并在需要html输出时从标记中进行回显或打印会更干净。非常感谢。我会看看我是否能清理代码D
    <?php if (get_post_meta($post->ID, 'Rental', true)) { ?>
        <li style="padding:3px 10px; line-height: 18px; height:34px">
        <strong><?php _e('Rental Potential / Actual', 'spanglishwebs') ?>:</strong> 
        <?php
            $priceWithoutFormat = get_custom_field('Rental');
            $priceWithFormat = number_format($priceWithoutFormat, 0, ',', '.');
            echo $priceWithFormat; ?>&euro;/Annual
        </li>
    <?php } else { ?>
        <li>Rental Potential / Actual: N/A</li>
    <?php } ?>