php的endif endwhile格式

By | 2010-03-17

寫了這麼久php,還是第一次看到endif endwhile這一種格式
(剛剛在查看某wordpress template時看到)
於是就google看看

原來這款格式是php3時候就有了,格式如下


if ($foo):
   echo "yep\n";
elseif ($bar):
   echo "almost\n";
else:
   echo "nope\n";
endif;

除此之外,還有endwhile / endswitch等等~
(想看詳細doc的,請到source中的php.net連結)

source:
http://www.phpbuilder.com/manual/en/migration.if-endif.php
http://docs.php.net/manual/control-structures.alternative-syntax.php

One thought on “php的endif endwhile格式

  1. wanglei

    我也是在 wordpress 上的看到的,然后Google 就到了这里。

Leave a Reply

Your email address will not be published. Required fields are marked *