if..endif 语法

使用 if(); elseif(); else; endif; 这一系列复杂的语句无助于 PHP 3.0 解析器的效率。因此,语法改变为:

Example#1 移植:旧有 if..endif 语法

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

Example#2 移植:新的 if..endif 语法

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

注意,在所有的声明中分号均改为冒号,除了末尾的 endif 以外。

原文:http://php.chinaunix.net/manual/zh/migration.if-endif.php

原文地址:https://www.cnblogs.com/zsmynl/p/3554985.html