I was just browsing a forum and someone asked about a PHP file they had found on the web. It has several spots like this in the code:
if ($REMOTE_ADDR == '') $ip = 'no ip'; else $ip = getHostByAddr($REMOTE_ADDR);
I have always thought brackets are needed to enclose what you want to do if the condition is true. Is there some other alternative, such as if it is on the same line you don’t?
There is also another line like this: if ($action != ''): mail('$adminaddress','Visitor Comment from YOUR SITE',
My instinct is to say this wouldn’t work, but I also don’t know if it is an outdated PHP file and it used to work?
you can do if else statements like this:
and then you can also write if – else in an alternate syntax:
with the alternate syntax you can also fall out of parsing mode like this:
But this gets really messy really fast and I won’t recommend it’s use (except maybe for template-logic).
and to make it complete: