1

即使对象已被调用,我也会在第 35 行的 page.class.php 中的非对象上调用成员函数 process_data()。

这是 index.php 提取显示正在实例化的对象

// require our common files
require("modules/module.php");
require("registry/objects/datetime.class.php");
require("registry/objects/page.class.php");


// load in all the objects
$datetime = new dateandtime;
$page = new page;
$module = new module;

然后它传递给 Process 类

        require("template.class.php");
        $template = new template($php_path . "controllers/themes/adm/" . $page . ".html");

        // Place in both commonly used language and page specific language
        $template->language($php_path . "controllers/language/en/adm/common.php");
        $template->language($php_path . "controllers/language/en/adm/" . $page . ".php");

        // Tell the page's module to load in data it needs
        $module->process_data("module_" . $page);

        // Output the final result
        $template->output();

正是在这一点上,PHP 正在抛出错误。module.php文件内容如下

class module {

    public function process_data ($child) {
        require($child . ".php");
        read_data();
        return true;
    }
}

我已经尝试将实例声明移动到第二个粘贴的代码中,但这会产生更多错误,因为“模块”调用的类也使用了一些“模板”类 - 所以同样的问题发生在更远的地方线。

我哪里错了她,或者完全错过了,我确定是后者,但我真的需要帮助。谢谢

4

1 回答 1

0

当您尝试调用对象方法时,它看起来好像变量 $module 不在范围内。你能在 $module->process_data("module_" . $page) 之前尝试 var_dump($module)。这个函数的结果是什么?快速解决方案可能是声明 $module 全局变量,但全局变量无论如何都不是一个好主意(但您可以检查它是否有效)。

于 2009-01-21T16:40:49.490 回答