【发布时间】:2011-02-09 12:59:52
【问题描述】:
这个要求只是为了开发人员的简单性和美观的代码。我正在构建一个模板系统,我真的希望一个对象变量简单地存在于所有函数中。这是一些代码:
图书馆员.php:
$class = "slideshow";
$function = "basic";
$args = array(...);
$librarian = $this; // I WOULD LIKE THIS TO BE PRESENT IN CALLED FUNCTION
...
return call_user_func($class.'::'.$function, $args);
...
幻灯片放映.php:
public static function basic($args) {
echo $librarian; // "Librarian Object"
}
谢谢! 马特·穆勒
【问题讨论】:
标签: php variables templating