您的位置:首页 > 其它

谈下最近学习hmtl5的一些知识:控制结构

2014-10-21 18:15 176 查看
控制结构例如 “if”, “for”, “foreach”, “while”, “switch”等。下面一个例子,“if”:

if ((expr_1) || (expr_2)) {
// action_1;
} elseif (!(expr_3) && (expr_4)) {
// action_2;
} else {
// default_action;
}
// wrong = no brackets, badly placed statement
if (expr) statement;

// wrong = no brackets
if (expr)
statement;

// good
if (expr) {
statement;
}

// wrong = inline assignment
if ($variable = Class::function()) {
statement;
}

// good
$variable = Class::function();
if ($variable) {
statement;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息