php – assign php function in .tpl file

how to assign a php function in a .tpl file?

suppose your function is this

function random_num($n=10)
return rand(0, pow(10, $n));
$smarty->assign(‘random’, random_num());

now go to your tpl file and write


this will fetch random function in .tpl file. if you are a smarty starter than remember you need to have smarty class defined for more about it please visit to know more