www.webdeveloper.com
Results 1 to 3 of 3

Thread: Not including files correctly

  1. #1
    Join Date
    Oct 2005
    Location
    California
    Posts
    603

    Not including files correctly

    shared IIS 6.0 server. Not in PHP safe mode.

    Problem: Some setting/directive (php.ini or IIS 6.0 setting I suppose) is keeping me from including files correctly.

    EXAMPLE 1:
    index.php: include('includes/file1.php');
    includes/file1.php: include('includes/file2.php');
    includes/file2.php: echo "HI THERE!";

    RESULT 1: This should print "HI THERE!", but does not work as explected. file1.php is included in index.php and therefore should reference other files as if it were in the same directory as index.php.

    EXAMPLE 2:
    index.php: include('includes/file1.php');
    includes/file1.php: include('file2.php'); //notice the omission of the "includes" directory in the call.
    includes/file2.php: echo "HI THERE!";

    RESULT 2: This DOES work. It should NOT work like this.

    But some setting is forcing the 2nd method.

    I couldn't find any directives in php.ini that would affect this. Maybe an IIS setting? It makes my code (and other 3rd party php code) nearly useless.

  2. #2
    Join Date
    Dec 2006
    Location
    Escaz˙ (Costa Rica) and Mallorca (Spain)
    Posts
    3,234
    It seems to me, it's exactly as described here

  3. #3
    Join Date
    Oct 2005
    Location
    California
    Posts
    603
    Thanks. It didn't give a solution, but it helped develop a vocabulary for the issue. Basically the problem is this:

    The current working directory should be the calling script. However, some configuration setting is causing each independent called file to be it's own current working directory. So that any file that the included file includes is relative to that included file, and not the calling script.

    Is there a way to change this in some configuration file?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles