Jump to content

Invoking Classes through a Nested Include


lifewater

Recommended Posts

Hello,

 

I apologize if this is a repeated question, but I did not see it while I was checking the first few pages. Here is my dilemma.

 

I am trying to make a script using classes, and I'm having trouble getting the class to work. Here is my situation

 

index.php is the main page, which includes a header (header.php) and then pulls data from my MYSQL database and displays it.

 

header.php displays the header and links associated with index.php. header.php also includes a config.php while contains a class in it. This class loads some default variables in a constructor like so and echos them:

 

<? class foo 
{ 
var $fooA; 
var $fooB; 
var $fooC; 
   function __construct()
   { 
      $this->fooA="This";
      $this->fooB="is";
      $this->fooC="Broken"; 
      echo fooA ." ". fooB." ". fooC." <br />\n"; 
   } 
}
?>


For some reason index.php loads header.php, but header.php does not load config.php....therefore nothing gets echoed. Is this a limitation of php or something wrong with my coding?

I'm sorry, I realize this wasn't specific enough  I have a small demo avaialble online for what i'm trying to do:

 

http://216.120.244.193/~lsdrift/test/index.php

 

there are 6 files there:

index.php

header.php

config.php,

 

and the*.phps versions of each file so you can see my code.  This is actually just a small example that I'm trying to do on a much larger scale, but I can't get it to work on a small scale either.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.