码迷,mamicode.com
首页 > Web开发 > 详细

PHP基础知识之流程控制的替代语法

时间:2016-10-24 09:48:57      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:知识   orm   either   round   back   nbsp   color   class   else   

PHP 提供了一些流程控制的替代语法,包括 ifwhileforforeach 和 switch

替代语法的基本形式是把左花括号({)换成冒号(:),把右花括号(})分别换成 endif;endwhile;endfor;endforeach; 以及 endswitch;

<?php if ($a == 5): ?>
A is equal to 5
<?php endif; ?>
 
<?php
if ($a == 5):
    echo "a equals 5";
    echo "...";
elseif ($a == 6):
    echo "a equals 6";
    echo "!!!";
else:
    echo "a is neither 5 nor 6";
endif;
?>

PHP基础知识之流程控制的替代语法

标签:知识   orm   either   round   back   nbsp   color   class   else   

原文地址:http://www.cnblogs.com/learnsimida/p/5991775.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!