Home  >  Article  >  Backend Development  >  一段PHP代码!该怎么处理

一段PHP代码!该怎么处理

WBOY
WBOYOriginal
2016-06-13 11:55:451076browse

一段PHP代码!

本帖最后由 u010250831 于 2014-04-26 22:46:36 编辑  if(is_array($today)): $i = 0; $__LIST__ = $today;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): ++$i;$mod = ($i % 2 )
?>

上面的代码是什么写法?“:”是什么符?懂得大神详细讲解下!
------解决方案--------------------
php 流程控制有两种语法结构。一种用大括号表示语句块,一种用冒号表示语句块。
大括号表示语句块的用得较多,这里就不说了。
使用冒号“:”来代替左边的大括号“{”;使用endif;、endwhile;、endfor;、endforeach;和endswitch;来代替右边的大括号“}”。

例如以下两段程序是一样的

$a=1;
$b=2;

if($a==$b){
echo 'a=b';
}else{
echo 'a!=b';
}



$a=1;
$b=2;

if($a==$b)
:echo 'a=b';
else
:echo 'a!=b';
endif

------解决方案--------------------
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]