note 86875 modified in control-structures.alternative-syntax by danbrown

From: Date: Sun, 04 Jan 2009 23:36:02 +0000
Subject: note 86875 modified in control-structures.alternative-syntax by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-148838@lists.php.net to get a copy of this message
Hello , when you going to make a script , you must try easist way to do and fastest way to parse .. using alternative-syntax is very useful to shorten your code e.g : If you want to do: <?php $a=1 ; if ($a==1) { echo "<table border=1><tr><td>$a is equal to one </td></tr></table> " ; } ?> You can do it using alternative-syntax as following : <?php $a=1 ; if ($a==1) :?> <table border=1><tr><td><?echo $a ;?> &nbsp;is equal to one </td></tr></table> <?php endif ; ?> So the HTML code Won't excuted until the condition is true [EDIT BY danbrown AT php DOT net: Contains a bug fix provided by (gmdebby AT gmail DOT com).] --was-- Hello , when you going to make a script , you must try easist way to do and fastest way to parse .. using alternative-syntax is very useful to shorten your code e.g : If you want to do : <?php $a=1 ; if ($a=1) { echo "<table border=1><tr><td>$a is equal to one </td></tr></table> " ; } ?> You can do it using alternative-syntax as following : <?php $a=1 ; if ($a=1) :?> <table border=1><tr><td><?echo $a ;?> &nbsp;is equal to one </td></tr></table> <?php endif ; ?> So the HTML code Won't excuted until the condition is true http://php.net/manual/en/control-structures.alternative-syntax.php

« previous php.notes (#148838) next »