Can I have a class method include a header file for me in PHP?

karaman

New Member
Please review the example code below, I have a class file that is loaded into a config file. The config file is then loaded into any page I build. Is it possible to include a header file the way I have in the show_header() method? It doesn't seem to work so how can I achieve this result?\[code\]// Core.class.phpclass Core{ public function show_header($page_name){ require_once 'includes/header.inc.php'; }}// config.inc.phprequire_once 'Core.class.php';$core = New core;// testpage.phprequire_once 'config.inc.php';$core->show_header('home');\[/code\]Here is the top part of the header.inc.php file I am trying to include into the page, it seems to work including it but it breaks the way the header file works.\[code\]//header.inc.php<?PHP//start page timer$session->get('user_id');$profiler = new Profiler;$profiler->start();//see if site is turned on/off$core->sitestatus($config['site_status']); \[/code\]This part gives me errors like this... \[quote\] Notice: Undefined variable: session in C:\webserver\htdocs\friendproject2\includes\header.inc.php on line 5 Fatal error: Call to a member function get() on a non-object in C:\webserver\htdocs\friendproject2\includes\header.inc.php on line 5\[/quote\]
 
Back
Top