[FX.php List] Embed php into HTML or vice versa?
Kevin Futter
kfutter at sbc.melb.catholic.edu.au
Thu Aug 31 20:22:00 MDT 2006
On 1/9/06 12:06 PM, "DC" <dan.cynosure at dbmscan.com> wrote:
> If you are not using smarty.... (which you should really take a look at)....
> ;-)
>
> A lot of PHP servers have 'short tags' turned on. This can be changed in
> php.ini file if it isn't on. you can replace the verbosity of
>
> <?php echo $variable ?>
>
> with the nice
>
> <?=$variable ?>
>
> Also, 'Alternative syntax for control structures" is something to look at in
> the PHP manual. Basically it involves using colon to open foreach and if (and
> other control structures) and using endforeach; and endif; to close them.
>
> These two ideas will allow you to tighten up the mixed HTML and PHP like so
> (at least i think it's cleaner! I added list-explode line for clearer variable
> assigns and I changed the closing anchor tag to be output in HTML instead of
> Kevin's suggestion to use a pragmatic PHP approach since I find it more
> readable and you avoid escaping doublequote):
>
> <? foreach($searchResult['data'] as $key => $value):
> list($currentRecord, $mod)=explode('.',$key); ?>
>
> <tr class="ver12">
> <td>
> <a href="famdetail.php?recid=<?=$currentRecord?>" >
> <?=$value['FamilyName'][0] ?>
> </a>
> </td>
> <? endforeach; ?>
>
> cheers,
> dan
Some good ideas there Dan, though personally I¹m not a fan of short opening
tags. The PHP manual itself recommends against them, and they can cause all
sorts of problems in XML environments, where they can (do) look like an XML
prolog.
--
Kevin Futter
Webmaster, St. Bernard's College
http://www.sbc.melb.catholic.edu.au/
------------------------------------------
This e-mail and any attachments may be confidential. You must not disclose or use the information in this e-mail if you are not the intended recipient. If you have received this e-mail in error, please notify us immediately and delete the e-mail and all copies. The College does not guarantee that this e-mail is virus or error free. The attached files are provided and may only be used on the basis that the user assumes all responsibility for any loss, damage or consequence resulting directly or indirectly from the use of the attached files, whether caused by the negligence of the sender or not. The content and opinions in this e-mail are not necessarily those of the College.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.iviking.org/pipermail/fx.php_list/attachments/20060901/98f5add2/attachment.html
More information about the FX.php_List
mailing list