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
    Regular Coder
    Join Date
    Jan 2013
    Location
    Australia
    Posts
    109
    Thanks
    21
    Thanked 0 Times in 0 Posts

    Require Once Not Working

    Hi.

    I have a couple of folders in my directory on is called system and other catalog. There is also a file called index.php

    The stuff that was on there I have copied that to a new file location in system the file is called startup.php this is now required once on index.php

    It doesn't seem to work this way

    Code:
    <?php
    
    require_once(DIR_SYSTEM . 'startup.php');
    
    
    ?>
    only will work this way.
    Code:
    <?php
    
    require_once('system/startup.php');
    
    
    ?>

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    If your directory paths have changed, you have likely broken it.
    PHP searches on two initial conditions: the current working directory of the EXECUTING script, and the include_path if not found in the current working directory.
    If you've changed the directories the files are in and they do have reliance on each other, than you must ensure that they are loaded from the current working directory of the executing script.
    Your options are either to:
    1. Provide an absolute path
    2. Add a base to the include_path
    3. Create relative from this file by making use of __DIR__ or dirname(__FILE__) on older versions of PHP.


    Of course, that assumes an issue with loading an included script. Since you've posted no errors and no description of a problem, I have simply guessed that.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Tags for this Thread

    Posting Permissions

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