RE: [PHP] mixing HTML and PHP code

From: Date: Fri, 12 Jan 2001 01:43:38 +0000
Subject: RE: [PHP] mixing HTML and PHP code
Groups: php.general 
Request: Send a blank email to php-general+get-34183@lists.php.net to get a copy of this message
As I said to my HTML Editors: Whenever you meet in your code: <? / ?> DO NOT TOUCH IT... It works - Programmers and Web Designers have nothing now to do together. That is what I love the most of PHP -- you can separate PHP Core and HTML extremely easily. Cheers, Maxim Maletsky. -----Original Message----- From: Alex Black [mailto:enigma@turingstudio.com] Sent: Friday, January 12, 2001 10:37 AM To: php-general@lists.php.net Subject: Re: [PHP] mixing HTML and PHP code > 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"; > ?> well, the first example is just improperly structured code. <table border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="top"> <?="$lAuthor: $author"?> (<?=$host?>)<br> </td> </tr> </table> or: echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n"; echo "<tr> \n"; echo "<td valign=\"top\"> \n"; echo "$lAuthor: $author ($host)<br> \n"; echo "</td> \n"; echo "</tr> \n"; echo "</table> \n"; ? and I have seen a _ton_ of examples of the latter, believe me. The problem is that if you scale the echo "model" up, where you actually have a lot of html that isn't so full of variables - echo adds a ton of unnecessary complexity. a point I made to another person: php is an html-embedded scripting language, not the reverse. if use use echo so much, you might as well just use mod_perl. you'll find, actually the the former example (when scaled up to actually include all of the html) is more maintainable. _especially_ if you have non-php aware staff that is editing markup. best, _alex > > "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 >> > > > > -- > 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 > -- 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 (#34183) next »