Jump to content


Photo

Classes Question


  • Please log in to reply
2 replies to this topic

#1 DaveTomneyUK

DaveTomneyUK
  • Members
  • PipPip
  • Member
  • 13 posts
  • LocationUK, England

Posted 14 June 2006 - 10:20 PM

Hi,

I am new working with classes and have a question each of my files as a call at the top and bottom to include my header and footer like below

require_once("header.php");
require_once("footer.php");

Is it possible to include them in a class so all I would need to add in my files are something like.

$generate->header();
$generate->footer();


#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 14 June 2006 - 10:36 PM

Yes...

<?php

class Generate
{
   function header()
   {
      require_once 'header.php';
   }
   
   function footer()
   {
      require_once 'footer.php';
   }
}

// Class initialization
$generate = new Generate;

$generate->header();

$generate->footer();

?>

~ D Kuang

#3 DaveTomneyUK

DaveTomneyUK
  • Members
  • PipPip
  • Member
  • 13 posts
  • LocationUK, England

Posted 14 June 2006 - 11:20 PM

Thanks that worked




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users