Topic: colon after if condition

What is this colon after if condition for? I have never met this before.

<?php if ($mod_restore): ?>

Re: colon after if condition

it is an alternative control structure in php
http://uk2.php.net/manual/en/control-st … syntax.php

3

Re: colon after if condition

It's a waste of bytes though ( endif; ...) and IMO you should stick to the good old curly brackets. most people do and thus it would make your code better readable for the majority.
But that's the good and the bad thing about php: There are always two million ways to do the same thing, so you can do what you please ... smile

The German PunBB Site:
PunBB-forum.de

Re: colon after if condition

I actually opted for that syntax to increase readability. There are enough curly brackets in e.g. profile.php as it is smile Nevertheless, it is an outdated paradigm, so I will consider changing it for 1.3.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

5

Re: colon after if condition

Shit. I only just learnt how to use it and its obsolete already.

Re: colon after if condition

I like those short stuff for small if statements, like setting a variable either of two things ...

Re: colon after if condition

i kinda like them for messy stuff in html, since <?php endif; ?> makes alot more sense than <?php } ?>