Reply to Re: Project Design

Your name:

Reply:


Posted by Kenneth Downs on 06/03/05 03:38

Richard Stride wrote:

>
> I am fairly new to PHP and have written an application for managing spam
> in a quarantine like environment.
>
> Now the problem has arisen that Branding will eventually come into the
> picture as well as localisation.
>
> I prefer to embed php code into the HTML segments of the page, the dynamic
> PHP components having been populated by middleware classes that can take
> care of all the business logic.
>
> But now I am finding that it might be better to write classes that
> generate blocks of HTML instead of having dynamic elements of PHP inside
> HTML.
>
> What have other users experiences been like? Do you prefer to write
> functions that generate HTML or do you prefer to have HTML blocks with PHP
> in them?
>
> Looking forward to reply's!
>

This has been well covered recently and there is a FAQ entry, but here is my
$.02.

The FAQ entry says it best, PHP is itself a templating system, separation of
logic and layout are accomplished by habit and practice, not by technology.

So if you look at templating systems, you will see stuff like:

<h1>{Title}</h1>

Whereas if you just assign pieces of HTML into a lot of variables, you have
this:

<h1><?=$Title?></h1>

The only difference is that in the second case you don't have to learn a new
language or parse the file.

You can also go the other way in building strings, such as this:

$HTML_BigOutput .= "<h1>".$Title."</h1>"

but I personally have found that cumbersome and problematic.

With all of that said, when we make a page "brandable" we identify the
smallest fragments of HTML that cannot be divided, assign them to
variables, and then include an HTML file, like so:

$Title = "Page Title";
$text = "This is some simple text";
include("HTML_Output.php");

....and the file HTML_Output.php looks like:

<html>
<head>
<title><?=$Title?></title>
</head>
<body>
<h1><?=$Title?></h1>
<?=$text=?>
</body>
</html>

You can then replace the HTML_Output.php file with something that has
different graphics, placement of objects and so forth.



--
Kenneth Downs
Secure Data Software, Inc.
(Ken)nneth@(Sec)ure(Dat)a(.com)

[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

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