Re: if syntax
| From: | Derick Rethans | Date: | Wed, 10 Jul 2002 18:34:23 +0000 |
| Subject: | Re: if syntax | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-106915@lists.php.net to get a copy of this message | ||
Martin Clifford wrote:
There are no brackets necessary if you only have one line of code to be executed in the case. For example: if($var == 1)This will certianly give a parse error, your sample should be: if ($var == 1)echo "Var equals 1";} else {echo Var does not equal 1";}
echo "Var equals 1";else
echo "Var does not equal 1";
But this is not valid: if($var == 1)Again, the sample should look like (but ofcourse this one does not work): if ($var == 1)echo "Var equals "; echo "1";} else {....}
echo "Var equals ";
echo "1";
else
echo "Var does not equal 1";
HTH MartinI know this is correct: if ($something) { ... } else { ... } But I recently saw someone use this instead: if($something): ... else: ... Is that also correct?? No brackets needed?"Alexander Ross" <alexross@bleen.net> 07/10/02 10:25AM >>>