We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

How to call php function with template variable

Development and Programming

vasin's avatar
vasin
12 posts
15 years ago
vasin's avatar vasin

Good day How to call php function with template variable ? For example - I have global variable like {testVar} I like to call php function, using {testVar} as parameter

<?php strlen({testVar}); ?>

But when I go to view, I have error

Parse error: syntax error, unexpected ‘{‘, expecting ‘)’ in /home/xxx/system/expressionengine/libraries/Functions.php(650) : eval()’d code on line 6

       
Frans Cooijmans's avatar
Frans Cooijmans
36 posts
15 years ago
Frans Cooijmans's avatar Frans Cooijmans

set the php-parsing stage to output (template preferences).

       
Greg Aker's avatar
Greg Aker
6,022 posts
15 years ago
Greg Aker's avatar Greg Aker

The variable still needs quotes around it when passing a string to strlen()

       
vasin's avatar
vasin
12 posts
15 years ago
vasin's avatar vasin

Greg Aker: like as

<?php strlen("{testVar}"); ?>

?

       
vasin's avatar
vasin
12 posts
15 years ago
vasin's avatar vasin

thanks. all works!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.