FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Embedding HTML Within a PHP Statement
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Embedding HTML Within a PHP Statement [message #175993 is a reply to message #175991] Mon, 14 November 2011 13:29 Go to previous messageGo to previous message
Erwin Moller is currently offline  Erwin Moller
Messages: 228
Registered: September 2010
Karma:
Senior Member
On 11/14/2011 2:07 PM, Balazs Nadasdi wrote:
> On Monday, November 14, 2011 11:10:15 AM UTC+1, Erwin Moller wrote:
>> Have you never seen constructs like these before?
>> <table>
>> <tbody>
>> <?php
>> foreach ($someDBResult as $oneRow){
>> ?>
>> <tr>
>> <td>
>> <?php echo $oneRow["firstName"]; ?>
>> </td>
>> <td>
>> <?php echo $oneRow["initials"]; ?>
>> </td>
>> </tr>
>> <?php
>> }
>> ?>
>> </tbody>
>> </table>
>
> more readable (i don't like this:<?php } ?>):
>
> <table>
> <tbody>
> <?php foreach ($someDBResult as $oneRow): ?>
> <tr>
> <td>
> <?=$oneRow["firstName"]; ?>
> </td>
> <td>
> <?=$oneRow["initials"]; ?>
> </td>
> </tr>
> <?php endforeach; ?>
> </tbody>
> </table>

Hi,

I agree it is more readable, but it also expects to have short_open_tag
set to on (or 1), which isn't always the case.
Many shared server environments this is set to off (0).
Hence, if you want to improve portability of your code, avoid those
short tags.
(Sometimes this can be overcome by using a .htaccess and override, but
that isn't always allowed either. You know: the straight-jacket shared
server.)

Of course, if you own the server and have no plans at all to ever move
your code, you can enjoy the short_open_tag. :-)
For myself, I stopped using it because of the above reasons.

Regards,
Erwin Moller

--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Smart File Downloader - simple script on xampp
Next Topic: Prevent unlink(...) warning
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Nov 25 04:37:50 GMT 2024

Total time taken to generate the page: 0.04305 seconds