Re: mixing HTML and PHP code

From: Date: Thu, 11 Jan 2001 23:45:56 +0000
Subject: Re: mixing HTML and PHP code
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-34154@lists.php.net to get a copy of this message
I have to agree with Jason on this one too. I work in a *production* enviroment, Ive worked on small (2k loc) to medium (45k loc) sites and I see no problem with echo "" accually I see a larger problem with going in and out of PHP, it breaks the consistancy. code snip from phorum <?PHP echo $lAuthor;?>: <?PHP echo $author; ?> (<?PHP echo $host; ?>)<br> <?PHP echo $lDate;?>: <?PHP echo $datestamp; ?><br> //---- <? echo "$lAuthor: $author ($host)<br>\n"; echo "$lDate: $datestamp<br>\n"; ?> I find the later easier to read, and modify, IMHO I cant see why it would be easier. Maybe just programming style, everyone to they're own. Chris Lee Mediawaveonline.com "Jason Murray" <Jason.Murray@melbourneit.com.au> wrote in message news:1595534C9032D411AECE00508BC766FB010528D0@MERCURY... > > if you have ever worked in a fast paced production environment, where > > html is changed sometimes 5 times a day, digging through hundreds > > of lines of: > > > > echo "<input type=\"text\" name=\"hello\" > > size=\"20\" > > value=\"$value\">" > > > > starts to make you insane. > > That's pretty ugly. > > echo "<input type='text' name='hello' size='20' > value='$value'>"; > > That's a bit better. > This is even better still: > > echo "<INPUT TYPE='TEXT' NAME='hello' SIZE='20' > VALUE='$value'>"; > > Now, I can see the PHP variable used in there a lot easier than I > could before. Syntax highlighting would bring it up more, too. > > > speaking as an html author, and a lover of php, _please_: > > > > <input type="text" name="hello" size="20" > > value="<?=$value?>"> > > > > it makes the code useable. > > Actually, it makes it less useable for me. > > > : _never_ and I do mean that _never_ use echo for printing html. > > > > it makes your apps impossible to change, and in a production > > environment, that's not ok. > > What if, halfway through a page, I figure out that I need to do a > redirect or set a cookie? > > I assemble *all* the page content into a single string variable, > and echo it out as the last thing the script does. This way I'm > free to play with HTTP headers right up to that time. > > However, each to their own - your way works for you and your team, > mine works for me and mine :) > > Jason > > -- > Jason Murray > jasonm@melbourneit.com.au > Web Design Team, Melbourne IT > Fetch the comfy chair! > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#34154) next »