Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2005
    Posts
    74
    Thanks
    0
    Thanked 1 Time in 1 Post

    Question Multiple require's causing issues [PHP5]

    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.
    Thanks,

  • #2
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    Use require_once


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •