Hi Michael,

One thing I'd suggest if you're learning PHP is to from the very start try as much as possible to avoid having PHP generate your HTML (as in your example).

I started coding PHP over 4 years ago using an e-commerce system that generated large amounts of the HTML and I still now have to occasionally work on it. I can tell you that debugging HTML is a scary task when it is being generated all over the place. It's a frequent complaint that database-driven/content-managed/whatever sites produce horrible HTML because of their "engines".

This is not really the right list for too much discussion on PHP itself but I'd suggest you separate out your HTML into "templates" which can be done using template engines as tricky (and some say overkill) as Smarty or as simple as using <?php echo $whatever; ?> in your HTML. The important thing being to only allow php code in your HTML that is responsible for actually generating the HTML. e.g. not database queries. In fact I was recently doing a quick update on the above system and realised the one improvement I'd do first would be to separate out the HTML as much as possible. A great place to get some idea of the approaches is sitepoint.com PHP forums; search for "php template" or similar.

I'll not go too far into the nitty-gritties as it could drift off-topic. I do however think that the way a lot of systems are built does make building valid standards compliant sites very difficult if not done carefully.


... a bit much to ask?

Just wondering if anyone knew of any such tutorials. Those on php.net
seem as if they were written by C programmers wanting to learn php. Yet
those on webmonkey are so old that they still use things like:

echo "<FONT COLOR='red'>Hi there";

Makes it very hard to help HTML newbies (who've learned standards-based
html from the start) learn PHP!

The best I could find was:
http://www.free2code.net/tutorials/programming/php/4/ Introduction_to_PHP.php

Any suggestions welcome!

****************************************************** The discussion list for http://webstandardsgroup.org/

Proud presenters of Web Essentials 04 http://we04.com/
Web standards, accessibility, inspiration, knowledge
To be held in Sydney, September 30 and October 1, 2004

See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list & getting help

Reply via email to