Re: [Nolug] PHP help

From: Jess Planck <jesse.planck_at_gmail.com>
Date: Fri, 18 Apr 2008 10:56:45 -0500
Message-Id: <198D851B-0B81-46B5-8E97-AF28BA78476F@gmail.com>

HA! Joey had throw PERL!

Here's a simple example:

/// put in file include.php
<?php
function spiffy_html( $text = '' ) {
     echo '<p class="nobody" id="nothing">';
     echo $text;
     echo '</p>';
}
?>

// put in file application.php
<?php include( 'include.php' ); ?>
<html>
<body>
<?php spiffy_html(); ?>
</body>
</html>

So right there you have separated SOME of your HTML/UI with your php
code. This example is very short, so it can be done a heck of a lot
better. The thing is in many cases you can get further thinking about
PHP as a template system itself. It can reduce complexity since in
most cases with Smarty and Flexy you will be working with the PHP API
and then working with an additional Template System API that is
typically not interchangeable. If you are thinking about template
systems because of caching features then in the above case you should
be looking toward memcache and others.

Also always remember just because you use "include( blah.php )"
doesn't mean that blah.php has to have any real PHP code. It could be
"include( blah.html )" for just sticking in HTML stuff.

For Petri..

Smarty Code: {function_name name1="some value" name2="some other value"}

  is really no more difficult to understand than

PHP Code: <?php function_name( 'some value', 'some other value' ) ?>

I think Joomla, Drupal and WordPress follow the PHP as template engine
system, so you can look to those complex applications for inspiration.

Jess

[ :P ] jess planck - http://funroe.net

On Apr 18, 2008, at 9:22 AM, Joey Kelly wrote:
> Pipeline vs. callback: http://www.perl.com/pub/a/2001/08/21/templating.html

___________________
Nolug mailing list
nolug@nolug.org
Received on 04/18/08

This archive was generated by hypermail 2.2.0 : 12/19/08 EST