【发布时间】:2012-03-22 06:57:19
【问题描述】:
index.php
require_once('smarty/Smarty.class.php');
$Smarty = new Smarty();
function do_something() {
global $Smarty;
echo "where is smarty?"
var_dump($Smarty);
$ObjSmarty->assign("teams_list", $teams_list);
}
get_active_teams();
没有转储和错误分配...
require_once('smarty/Smarty.class.php');
$Smarty = new Smarty();
function do_something() {
global $Smarty;
echo "where is smarty?"
var_dump($GLOBALS);
var_dump($GLOBALS["Smarty"]);
}
get_active_teams();
全局转储显示 Smarty,当我转储 $globals["smarty"] 时什么也没有。怎么回事。
我没有课是这个问题吗?
如何在不使用声明类的情况下分配给 php 函数中加载的 smarty 对象?
【问题讨论】:
-
您在第一个示例中将其称为 $Smarty 和 $ObjSmarty - 这是您的代码中的拼写错误还是实际存在?