【发布时间】:2012-05-09 01:32:17
【问题描述】:
我在 Wordpress 环境中的主题上创建了这个课程。
class Theme {
function __construct()
{
add_action('after_setup_theme', array(&$this, 'do_this'));
}
function do_this()
{
require_once('helper_functions.php');
}
}
$theme = new Theme();
在 helper_functions.php 中我有:
function get_image()
{
return 'working';
}
但现在我很困惑,因为当我执行此操作时
echo $theme->get_image();
它不起作用....但是如果我直接调用它,它会像这样工作:
echo get_image();
但我想既然用的是类方法,就需要用类对象来获取类方法……为什么可以直接调用呢?
【问题讨论】: