If you want to actually call the function by name in Smarty, you can’t just store the function name as a string — instead, you typically need to register it as a Smarty plugin/helper and then call it.
Steps:
1.Register the function in PHP:
<pre> <?php // Register PHP function as a Smarty plugin $smarty->registerPlugin("function", "myCustomFunction", "myCustomFunction"); // Define the function function myCustomFunction($params, $smarty) { return "Hello " . $params['name']; } ?> </pre>
2.Call it in your Smarty template:
<pre> {myCustomFunction name="Alice"} </pre>