Include PHP-file in Smarty
Posted: August 8, 2010 Filed under: Programming | Tags: code, php, programming, smarty Leave a comment »I’m teaching myself PHP and Smarty these days, and today I ran across a common problem:
«How do I include a PHP-file – or execute PHP-code – when using the Smarty template engine?»
After banging my head against the wall for a couple of hours, I finally found the solution. To include a PHP-file in a Smarty template, use the following code:
{include_php file=”/path/to/somefile.php”}
You can also use the following code to run and/or execute PHP-code within Smarty:
{php}
include(“includes/myname.php”);
{/php}
Hope this blog post helps some poor soul one day… Keep hacking.

Recent Comments