Re: html code blocks

From: Date: Wed, 23 Aug 2000 21:31:32 +0000
Subject: Re: html code blocks
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-13239@lists.php.net to get a copy of this message
On Wed, 23 Aug 2000, Brad Sacks wrote: > I have been exposed to a lot of asp in the last few months and there is > a cool thing that it can do. That is get around echo (response.write) > statements, like this; > <% if blah then%> > > <html code block> > > <%else if blah%> > > <html code block> > > <%end if%> > > asp will actually load the html inside the condition statement that is > met and ignore the rest. Of coarse asp has a lot of other things that > suck, but this is cool. I am pretty new to both asp and php, but can php > do this?. Does it work the same way? It's more or less the same, yeah. And PHP does it with a lot less overhead ;) <html><body> <p>Some text, html block, etc.</p> <ul>A list of variable data <li>First element <li>Second element <? if ($userID > 5) { ?> <li>First conditional element <li>Second conditional element <? } else { ?> <li>First alternate element <li>Second alternate element <? } ?> </ul> </body></html> By the same token, you can put html blocks inside loops. <table><tr><th>Key</th><th>Value</th></tr> <? while( list($key,$val) = each($array) ) { ?> <tr> <td><?= $key ?></td><td><?= $val ?></td> </tr> <? } ?> </table> And so on. Matt

« previous php.general (#13239) next »