Reply to Re: Mangled Code Mess

Your name:

Reply:


Posted by bill on 12/15/06 22:46

Double Echo wrote:
> Bill,
>
> Sorry for not getting back sooner... had a lot of work interrupting my
> newsgroup time. :-)
>
> Here-doc allows you to basically print out whatever is between the
> pattern you choose.
>
> I use ENDOFHTML but you could use ENDOFCODE or whatever.
>
> Perl has a similar construct:
>
> print <<ENDOFHTML;
> ENDOFHTML
>
> Notice the semi-colon at the top, PHP is a bit more "correct" putting
> the semi-colon at
> the end:
>
> print <<<ENDOFHTML
> ENDOFHTML;
>
> PHP also uses "<<<" whereas Perl uses "<<".
>
> Anyway, embedded PHP programs were the rave a couple of years ago, and
> people were doing
> it trying to create really dynamic pages, but it's really messy as
> you've found out to do it that way.
> It's easier to print <<<EDNDOFHTML because you can actually use ' and "
> in the block without trouble. There are also a lot of web servers that
> don't like embedded
> PHP in HTML docs and will barf or ignore it if you attempt it. So, it's
> better to embed HTML in PHP,
> and save yourself the hassle. One note, be careful about the placement
> at the end, the
> end tag _must_ be over at the left, and no space after it, or it won't
> work.
>

THank you. I like to embed the html in the php, but having to
escape all the quotes was killing me - this is much nicer.
bill
>
>
> bill wrote:
>> see end of post:
>>
>> Double Echo wrote:
>>> This is old-style dirty PHP programming. There are a lot of stupid
>>> programmers
>>> who mingle/mangle code like this trying to be cute. Instead of some
>>> HTML
>>> with PHP thrown in, reverse it. Have PHP with HTML thrown in. PHP
>>> should be the control, HTML should not be.
>>>
>>> <?php
>>>
>>> $var = 1 + 1 ;
>>>
>>> print <<<ENDOFHTML
>>> <html>
>>> <table>
>>> <tr>
>>> <td>
>>> $var
>>> </td>
>>> </tr>
>>> </table>
>>>
>>> ENDOFHTML;
>>>
>>> $some_more_php = 2 + 2 ;
>>>
>>> print <<<ENDOFHTML
>>> $some_more_php
>>> ENDOFHMTL;
>>>
>>> ?>
>>>
>>> A lot of web servers won't be set up for HTML-with-PHP but if you have
>>> a web server with PHP enabled, you can always throw in HTML.
>>> Programmers
>>> who mix PHP into HTML just don't know how to program cleanly.
>>>
>>> -DE-
>>>
>> DE.
>> for a newbie, who likes your style, please reference or explain the
>> syntax:
>>
>> print <<<ENDOFHTML
>>
>> bill
>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация