php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22865 including files from higher brother dirs
Submitted: 2003-03-24 22:28 UTC Modified: 2003-03-25 05:14 UTC
From: josmith at albertc dot on dot ca Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 4.3.1 OS: WinNT 5 and Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: josmith at albertc dot on dot ca
New email:
PHP Version: OS:

 

 [2003-03-24 22:28 UTC] josmith at albertc dot on dot ca
ok... 
index.php
    folder1
        file1
    folder2
        file2

That is the dir structure.

file1 'include()'s file2 and file1 is included in index. When file1 is called directly from the browser it includes file2 (by using include "../folder2/file2"). However, when file1 is included in index.php the path to file to (located in file1) must be absolute, it cannot be relative (although when fil1 is called directly the path to file2 can be relative). Using any relative path does nto appear to work in this rare case.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-25 05:14 UTC] mgf@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Relative paths in include/require are always relative to the initial script, *not* to the file doing the include-ing.  Thus:

  - when file1 is called directly, the relative path for include-ing file2 is indeed ../folder2/file2

  - when the original call is to index.php, which includes file1, which includes file2, the relative path to file 2 is ./folder2/file2 (relative to index.php, *not* file1), even from within file1.

You will need to use some kind of tracking of the base path for the current invocation.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 23:01:32 2024 UTC