PHP Template Engine - Page 2
The php function extract does the heavy lifting of PTE. Most code is already written using arrays or objects. Extract is used to turn an associative array into variables where the key is the variable name, and the value is the value of the new variable. Even in object oriented code, it is easy to take an object and make all variables available to the template from the object with a single simple line of code.
// inside an object's function $this->someExampleVar = 'Testing'; extract( get_object_vars( $this ) ); include( 'template.php' );
And template.php would look something like
Welcome, <?= $someExampleVar; ?>
Extract can also be used on database results
extract( mysql_fetch_assoc( $resultHandle ) );
Continue Reading on Page 3
Jump to page: _1_ | _2_ | _3_ | _4_ | _5_ | _6_
Thank you for reading! Feedback may be left by using the contact form
Interesting and/or informative comments will be posted on the article comment page.
For web site hosting I recommend - www.bluehost.com

Honestly, Tim is one of the best coders I have ever used.
He constantly added to my software and wasn't happy until I was happy.