什么是“:"在PHP中意味着什么? [英] What does ":" mean in PHP?
本文介绍了什么是“:"在PHP中意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复: PHP中的:"是什么?
:
在以下PHP代码中是什么意思?
What does the :
mean in the following PHP code?
<?php
while (have_posts()) : the_post();
?>
推荐答案
It's called an Alternative Syntax For Control Structures. You should have an endwhile;
somewhere after that. Basically, it allows you to omit braces {}
from a while to make it look "prettier"...
根据您的修改,它称为三元运算符(这是第三部分).基本上,这是作业的简写.
As far as your edit, it's called the Ternary Operator (it's the third section). Basically it's an assignment shorthand.
$foo = $first ? $second : $third;
等于说(短一点):
if ($first) {
$foo = $second;
} else {
$foo = $third;
}
这篇关于什么是“:"在PHP中意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文