View Full Version : Multiple require's causing issues [PHP5]

03-25-2009, 08:41 AM
I've got an odd issue (well odd to a newbie like me)...

I have 3 PHP functions
- index.php // index page for web
- Database.class.php // Database Interface
- Files.class.php // File System Interface

Within index.php I have the following:
require 'Database.class.php';
require 'Files.class.php';
This allows index.php to access the Database & Write to the file system (so far so good).

Within Database.class.php I have the following:
require 'Files.class.php';
This allows Database.class.php to have access to Write to the file system if the database encounters issues.
This is also where the problem occurs - the "require 'Files.class.php';" isn't liked - if I comment out this line my page runs fine.

Note that I don't actually create an instance of Files in Database yet (that was my next step - going to try that now but I assume this will fail - or at least be bad practice without the expected 'requires' in Database.class.php).
Any clues as to why this is not working? What would be the correct approach for PHP5?

Any help/hints would be much appreciated.

03-25-2009, 10:24 AM
Use require_once