php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #41460 include_path is applied only to cwd, not the current script directory
Submitted: 2007-05-21 14:54 UTC Modified: 2007-08-17 08:28 UTC
From: tayloj1 at uk dot ibm dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tayloj1 at uk dot ibm dot com
New email:
PHP Version: OS:

 

 [2007-05-21 14:54 UTC] tayloj1 at uk dot ibm dot com
Description:
------------
The include_path is applied only to the current working directory, not the current script directory.

The statement
	"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. "
is contradicted by the following experiment (tested on Windows and php 5.2.2):




Reproduce code:
---------------
Directory layout:

\myScriptDir
	\a.php 	<?php include 'b.php' ?>

\myWorkingDir
	\php.exe
	\php.ini	[...] include_path='include1;include2' [...]
	
Execute:
\myWorkingDir> php \myScriptDir\a.php




Expected result:
----------------
Expected attempted file reads (if the documentation were correct):

"Files for including are first looked in include_path relative to the current working directory..."
\myWorkingDir\include1\b.php
\myWorkingDir\include2\b.php
"...and then in include_path relative to the directory of current script"
\myScriptDir\include1\b.php
\myScriptDir\include2\b.php


Actual result:
--------------
Actual attempted file reads:

\myWorkingDir\include1\b.php
\myWorkingDir\include2\b.php
\myScriptDir\b.php

Obtained by stepping through the code with a debugger (namely _php_stream_fopen_with_path() in plain_wrapper.c) and confirmed with processmonitor, a tool which can monitor filesystem activity (http://www.microsoft.com/technet/sysinternals/utilities/processmonitor.mspx)

The documentation should read:

"Files for including are first looked for in each include_path entry relative to the current working directory,  and then in the directory of current script."

Note: the documentation provides an example after the offending statement. That example holds true against the actual behaviour of the engine, because the include path is just '.'.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-17 08:28 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 13:01:33 2025 UTC