在PHP中使用if,foreach,while等替代冒号语法的重要好处是什么?

Usual if syntax

if(){
}else{
}

Using colon

if:
else:
endif;

I am going through yii framework, and I see everywhere in the template the author has used the alternative colon syntax. I was wondering if there's a significant advantage ?

It's just a matter of taste, really. If you come from a VB coding background, you may find it more familiar to use the colon syntax. Some people find that some code is easier to read when using Colon syntax. Use it if you find it appropriate.

One can argue about it, but IMO the alternative syntax is much easier to read when you use control structures in HTML. Especially when they are nested.

The "closing" tags (e.g. <?php endif; ?>) are much more descriptive and they are easier to spot in HTML than <?php } ?>.

I would not use them in "normal" code though. There it makes the code actually harder for me to read. They feel somehow out of place. But I guess this is a matter of habit.

The way I've seen this used the most is in templates, it seems people find it more readable. Another reason would be being used to them when coming from another language (Like as said by Andreas Visual Basic).

Other than that there's no advantage to using it, it's just a different notation.