user1919320
user1919320

Reputation: 21

PHP in HTML-Template file - Smarty Engine

I am using at the moment the Smarty PHP Engine. Now I want to add a little bit of PHP-Code to the template file, like so:

{php}echo "asdf";{/php}

But when I open the browser this error appears:

Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template

What seems the problem, and how can I fix that?

Upvotes: 2

Views: 148

Answers (2)

Praveen Puglia
Praveen Puglia

Reputation: 5641

{php}
// including a php script directly from the template.
include('/path/to/display_weather.php');
{/php}

This way you can embed php codes into smarty template files. check this for reference http://www.smarty.net/docsv2/en/language.function.php.tpl

Upvotes: 0

XtrmJosh
XtrmJosh

Reputation: 949

{php}echo("Hello, world!");{/php}

Maybe this will work instead?

Upvotes: 1

Related Questions