Reply to Re: Mangled Code Mess

Your name:

Reply:


Posted by Double Echo on 12/11/06 13:24

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-

Skijor wrote:
> I have inherited a php script that nests php, javascript, and html.
> How do I clean up code like this:
> I think I can move the javascript into a seperate .js file at the
> least. What about the nesting of php inside the html?
>
> <?php
>
> ...snip...
>
> function ShowCart()
> {
> ...
> ?>
> <html>
> ...
> <script language="JavaScript">
> function UpdateQty(item, backPage)
> {
> ...
> }
> </script>
> </head>
> <body bgcolor="#ffffff">
> ...
> <?php
> while($row = @mysql_fetch_array($result))
> {
> ...
> ?>
> <tr>
> <td width="15%" height="25">
> <font face="verdana" size="1" color="black">
> <select name="<?php echo $row["itemId"]; ?>"
> onChange="UpdateQty(this,'<?php echo $_GET['back']; ?>')">
> ....
> }
>

[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

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