php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42570 require not finding files that are within filesystem
Submitted: 2007-09-05 19:02 UTC Modified: 2007-09-06 22:26 UTC
From: development at domain51 dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.2.4 OS: Mac OS X 10.4
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: development at domain51 dot com
New email:
PHP Version: OS:

 

 [2007-09-05 19:02 UTC] development at domain51 dot com
Description:
------------
When including/requiring file within the scripts path, it does not pay attention to the original scripts path.  file_exists() and is_readable() will return true, but require/include will produce an error.

Reproduce code:
---------------
<?php
// base-file.php
require 'include/some-file.php';
?>
<?php
// include/some-file.php
require 'file-that-exists.php';
?>
<?php
// file-that-exists.php
echo "Hello, I exist";
?>

Expected result:
----------------
Hello, I exist

Actual result:
--------------
Warning: include(file-that-exists.php) [function.include]: failed to open stream: No such file or directory in /path/to/some-file.php on line 3

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-05 19:10 UTC] development at domain51 dot com
I just attempted this code on a Linux (Ubuntu Feisty Fawn, Server) and did not receive the warning/fatal error.  Copying that code back to my Mac OS X box, the code did have the same error.

This appears to be OS X related.

The code to reproduce is available from: http://plumb.domain51.com/sandbox/bug42570.tar.bz2
 [2007-09-06 10:58 UTC] jani@php.net
What did you set include_path to be? And where are the files located..?
(it's not very clear now..)
 [2007-09-06 15:05 UTC] development at domain51 dot com
Sorry for not being more explicit.

The include_path is not touched during this execution and is left as it 
is compiled from the base.  In this case, the Mac's include_path is set 
to "/path/to/php" where the PEAR files are stored without the "./:" at 
the beginning as is the normal php.ini file setup.

Properly setting the include_path does handle this, though for some 
reason I had it in my head that the current working path was always 
prepended to the include_path.

Feel free to mark as bogus...
 [2007-09-06 22:26 UTC] jani@php.net
Current working dir isn't used by default. So this is bogus.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 16 11:01:33 2025 UTC