从 smarty 访问 PHP 文件的变量(本地或全局) [英] Accessing a variable (local or global) of PHP file from smarty

查看:31
本文介绍了从 smarty 访问 PHP 文件的变量(本地或全局)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含一些局部和全局变量的 php 文件(例如 $foo)
从此文件中调用了一个 smarty 对象.
如何在不更改 PHP 文件的情况下从 smarty 脚本访问 $foo?

I have a php file that has some local and global variables (e.g. $foo)
an smarty object is called from this file.
How can I access $foo from smarty script without changing PHP file?

谢谢

推荐答案

你不能.您必须在 PHP 文件中将其分配给 smarty.

You can't. You have to assign it to smarty within the PHP file.

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

这篇关于从 smarty 访问 PHP 文件的变量(本地或全局)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆