Reply to Re: standard coding...

Your name:

Reply:


Posted by Chung Leong on 01/12/06 05:23

Domestos wrote:
> Hi all,
>
> I was wondering if there is a standard when mixing PHP and HTML script on a
> page... and if there were any articles on this subject...

Not really. That's one nice thing about PHP--there is no orthodoxy.

> for example... which is better or more standard....
>
> <html>
> <head>
> <title>title text</title>
> </head>
> <body>
> You name is <?php $name?>
> </body>
> </html>

That's the style I prefer. Echo HTML from PHP becoming a huge pain when
the page makes use of Javascript. Instead of plain-o echo, I usually
use a function with a short name, as almost nearly everything output
needs to be escaped for HTML special characters.

Example:

function P($s, $flags = 0) {
$s = htmlspecialchars($s);
if(!($flags & NO_BR_TAGS)) {
$s = nl2br($s);
}
echo $s;
}

Then scatter throughout my HTML:

.....
<tr><td><a href="<? P($url) ?>"><? P($title) ?></a></td></tr>
....

[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

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