2

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?

0

2 Answers 2

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

Maybe this will work instead?

Sign up to request clarification or add additional context in comments.

1 Comment

This doesn`t work... The error also shows up wenn there is no content in {php}{/php}
0
{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

5 Comments

That also doesn`t work - the error shows up when there is no content between the two PHP tags
can you tell me why there is no content inside two php tags??
That was only for testing ;) I checked if this error also appears when no PHP code is between the two php tags...
I don't see why you should be having an error.. smarty.net/docsv2/en/language.function.php.tpl here they have done things we do in normal php. just inside those php curly tags. What is the exact error you are getting ?
Sorry to "bump" this, but it looks to me like a compiler issue, like your installation of Smarty is bad. Did you find a result?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.