You are here: Best way to output HTML from PHP « PHP Programming Language « IT news, forums, messages
Best way to output HTML from PHP

Posted by bizt on 09/28/09 12:01

Hi,

When I create a website in php I may have a page called products.php.
This script will contain any code required to produce a list of
products and build them into an array of objects perhaps. At the
bottom of the script I would have the following:

include_once('template.products.php');

This page will be the HTML with embedded PHP to output the list of
products:

<table ...>
<?php foreach($arProducts as $product): ?>
<tr>...</tr>
<?php endforeach; ?>
</table>

This appears very similar to something like Smarty exept I prefer to
have the use of objects and their methods when using the template.
Also I read an article on it that made a point that Smarty doesnt
really do much more than PHP as a template engine (as my above example
demonstrates).

Now XSLT is something I dont really have a lot of practical experience
in. I know how to create an XSL file but how is it best used in PHP.
Should the XSL be used to output a whole HTML page <html>...</html> or
just simple a table or something. I would have to convert my data to
XML to perform the transformation and this just seems like an extra
process required from my own technique. XSLT has been around for a bit
now and it would seem with the added support for it in PHP5 it is very
useful

Anyway, the point of this post is just to get peoples opinions on
outputting the front end of a page. My technique of using PHP for
templating works well for me but I may be wrong in other
circumstanses. Any guidance on this area would be much appreciated

Cheers

Burnsy

 

Navigation:

[Reply to this 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

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