One of the best things that ever happened to me (with regards to
writing PHP) was deciding not to embed it in HTML anymore.

I either:
a) generate the HTML from classes I've built (HTML, Forms, Tables,
Images, etc) or use an equivalent PEAR class

- or -

b) Use Smarty templates...in which I still generate the HTML that will
go to the template (where required) with the HTML generation classes.

The advantages are abundant.

I can't imagine having to maintain some of the code I saw in the
examples above. My favorite WTF was with this snippet:

$imgHTML = '<img src="' . $url . '" alt="' . $alt . '" title="' . $alt
. '" class="' . $imgclass . '" />';

Holy crap...REALLY!?

All that string concatenation and there's not even width/height
attributes in there!

That would look like:

$i = new Image('path/to/image/file');
$i->__set(array('class'=>$imgClass, 'alt' => $altText));
$i->toHtml();

Being able to change every image tag in a site by editing the
class/method that created is just too big an advantage not to use. Not
to mention the auto-generated width/height attributes, the ability to
auto-produce thumbnails and fullsize images from a single file...

After struggling through the beginnings, I wrote classes to generate
basic HTML elements, then tables, then forms, then images.

It saved me a bunch of time and taught me to see the website as an
application...not as a web-page with pieces of data in it.

Somehow, coming to that bit of knowledge was very helpful to my life
as a programmer.

Good luck,

John Corry

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to