php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #36160 include/require ../ relative to current script
Submitted: 2006-01-25 22:55 UTC Modified: 2010-12-22 12:50 UTC
From: ovdspek at liacs dot nl Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.1.2 OS: *
Private report: No CVE-ID: None
 [2006-01-25 22:55 UTC] ovdspek at liacs dot nl
Description:
------------
http://php.net/include/

> then in include_path relative to the directory of current script. 
> If filename begins with ./ or ../, it is looked only in include_path relative to the current working directory. 

Could the 'relative to the current script' also be applied to includes/requires that start with ../?

Reproduce code:
---------------
include('../common.php');

Expected result:
----------------
-

Actual result:
--------------
-

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-25 22:56 UTC] tony2001@php.net
It is.
 [2006-01-25 22:59 UTC] ovdspek at liacs dot nl
It's not.
And if you're sure it is, could you update the documentation?
 [2006-01-25 23:06 UTC] tony2001@php.net
What makes you think it's not relative to the current script?
 [2006-01-25 23:09 UTC] ovdspek at liacs dot nl
The fact that the documentation says it's not (it says it's only relative to the current working directory).
 [2006-01-25 23:30 UTC] tony2001@php.net
Maybe we're looking to different docs?
-----
Files for including are first looked in include_path relative to the current working directory and then in include_path relative to the directory of current script. E.g. if your include_path is ., current working directory is /www/, you included include/a.php and there is include "b.php" in that file, b.php is first looked in /www/ and then in /www/include/. If filename begins with ./ or ../, it is looked only in include_path relative to the current working directory.
-----
(c) http://php.net/include

 [2006-01-25 23:31 UTC] ovdspek at liacs dot nl
Last sentence of your quote:
If filename begins with ./ or ../, it is looked only in
include_path relative to the current working directory.
 [2010-12-22 12:50 UTC] johannes@php.net
-Status: Open +Status: Bogus -Package: Feature/Change Request +Package: *General Issues
 [2010-12-22 12:50 UTC] johannes@php.net
This works as designed and documented.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Jun 17 13:08:35 2026 UTC