开发者

smarty php variable not appearing

开发者 https://www.devze.com 2023-01-12 20:19 出处:网络
I am using the smarty templating system for php. I have the following within a .tpl file: <a href=\\\"{/literal}/view/{$tablename}/

I am using the smarty templating system for php. I have the following within a .tpl file:

 <a href=\"{/literal}/view/{$tablename}/

where $tablename is a php variable defined in the php file that calls the开发者_高级运维 .tpl

$tablename = 'string';

However running the script only

href="/view//"

is visible. What am I doing wrong?


This

$tablename = 'string';

is not enough to populate a variable into Smarty.

You need to use

$Smarty->assign("tablename", $tablename);

$Smarty being your initialized Smarty object, of course.


Are you assigning to variable to the smarty instance? e.g with assign()?

 $smarty->assign('tablename', $tablename);

See also the manual page on assigning variables from PHP

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号