![]() |
| ||
| beginner question Hey I'm a php beginner and I'm having some problems with the website I'm testing with. I'll show you first the relevant code. index.php: <?php stdlib.php: <?php Page.php: <?php The error I'm getting now that I've put in the autoload function is: Fatal error: Cannot instantiate non-existent class: page in /home/content/t/h/r/threepio/html/seth/php/index.php on line 3 All of these files are in the same directory, so I'm not sure why it can't find the Page class. Anyone have an idea? |
| ||
| Re: beginner question Where is the variable $class_name coming from and how is it populated? On line 3 of index.php, you have $page = new Page(); but, you never defined the class Page() in stdlib.php. I see you did it on Page.php but this will only have a local scope of the page its defined in. |
| ||
| Re: beginner question For interests sake, what happens when you replace: include"stdlib.php"; with include "Page.php"; ? Try transforming Page into lowercase as well.. |
| ||
| Re: beginner question buddylee17: The variable $class_name is passed to the autoload function when the it comes to a class that is not defined. At that point it includes the class it couldn't find with ".php" appended on the end. MickRip: And yes I could replace stdlib.php with Page.php, but the idea is that this way, I could include many classes, in individual files, without "including" each. |
| All times are GMT -4. The time now is 12:01 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC