1
即使調用了對象,我也會收到「在第35行的page.class.php中的非對象上調用成員函數process_data()」。PHP中可能存在的多實例對象問題
這裏是表示對象在index.php提取被instantised
// 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;
}
}
我已經試過實例聲明移到第二粘貼代碼中,而是產生更多的錯誤,因爲類「模塊」在隨後的使用要求一些「模板」類也是如此 - 所以相同的問題發生在更後面。
我怎麼會錯她,或完全失蹤,我敢肯定它是後者,但我真的需要幫助。謝謝
var_dump確實返回null。我以前嘗試過全球,這並沒有解決問題。 我已經閱讀了關於對象和類的文檔,但這並不是啓發我;當然沒有跨多個文件/類的問題。 – jakeisonline 2009-01-21 16:45:07