lifewater Posted March 15, 2007 Share Posted March 15, 2007 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? Link to comment https://forums.phpfreaks.com/topic/42895-invoking-classes-through-a-nested-include/ Share on other sites More sharing options...
per1os Posted March 15, 2007 Share Posted March 15, 2007 Are you doing this? $foo = new foo(); Link to comment https://forums.phpfreaks.com/topic/42895-invoking-classes-through-a-nested-include/#findComment-208331 Share on other sites More sharing options...
lifewater Posted March 15, 2007 Author Share Posted March 15, 2007 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. Link to comment https://forums.phpfreaks.com/topic/42895-invoking-classes-through-a-nested-include/#findComment-208439 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.