Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2010
    Posts
    19
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question please help me with php class

    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.
    PHP Code:
    //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 Code:
    <?php echo  $header->this_header('home');?>
    page is running without any error but does not show header file data here.
    Last edited by Inigoesdr; 12-15-2010 at 04:20 PM.

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    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() the file.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •