dougan1330 2011-08-18 19:24
浏览 34
已采纳

PHP和HTML格式,超级基本问题

I got to a phase in my code where I have too much code and too much HTML is depended on the consequences of some server conditions.

I simply want to know, is there any way to get around the:

<?php if (cond) echo '<p class="someclass">some HTML</p>'; ?> 

?

I just wish there was something like in C where you can simply go like:

#ifdef x 
    do_a_lot_of_html_stuff;
#endif

All I can see that I can do now is go like:

<?php if (x) require_once("includes/all_needed_part.php"); ?>

Thanks !

  • 写回答

10条回答 默认 最新

  • duanjiangzhi6851 2011-08-18 19:27
    关注

    Not exactly sure what you're asking, so if I am understanding your question correctly, you're looking for a way to print off blocks of HTML with PHP?

    <?php if ($a == $b): ?>
      <div>a == b</div>
      <p>a is equal to b</p>
    <?php else: ?>
      <div>a != b</div>
      <p>a is not equal to b</p>
    <?php endif; ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(9条)

报告相同问题?