View Full Version : please help me with php class

12-15-2010, 02:57 PM
i have a problem in class where i want to set headers. if i am at my website home page then i can add home-header.php if on other page then i can show header witch i want. here is my code of class.

//get headers class

class get_header{
var $home_header = '../include/home-header.php';
var $employee_header = './include/headers/employee_header.php';
var $employer_header = './include/headers/employer_header.php';
function this_header($head){
if($this->head == 'home'){
$show_header = $home_header;
else if($this->head == 'employee'){
$show_header = $employee_header;
else if($this->head == 'employer'){
$show_header = $employer_header;
return $show_header;
}//end of fucntion
}// end of class
//create instance of get_header class here...
$header = new get_header();

now at my home page i coded this blow...

<?php echo $header->this_header('home');?>

page is running without any error but does not show header file data here.

12-15-2010, 04:22 PM
Your this_header() method isn't getting the contents of the file, it's just a string representing the path to the file. You need to include() (http://php.net/include) the file.