|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-01-03 17:00 UTC] php at kingsquare dot nl
Description:
------------
On Windows 7, 'include' fails to load files from some folders in the include_path,
when the 'include_path' is configured like.
include_path = ".;C:\xampp\php\PEAR\;C:\myApp\"
It seems that, when starting the include path with '.;', everything after the
second folder (e.g. C:\myApp\ and further ) is ignored by the include-command.
When '.;' is removed from the include_path, everything works as expected.
This behaviour only appears when using PHP as CLI.
Test script:
---------------
<?php
//make sure C:\myApp\MyClass.php does exists!
set_include_path('.;C:\xampp\php\PEAR\;C:\myApp\');
include 'MyClass.php';
$obj = new MyClass();
print_r($obj);
Expected result:
----------------
Some info about the $obj-object
Actual result:
--------------
PHP Fatal error: Class 'MyClass' not found in <testscript.php>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 00:00:02 2025 UTC |
From CLI on Windows 7, when I call include() on a file that is in my include_path there are some very strange results. Basically the outcome is that the file is NOT included, and a new file gets created at the same level as the original script. I have tried to replicate on BSD, CentOS, Debian, Ubuntu, WinXP. All of these work perfectly with no bug. # php --version PHP 5.3.1 (cli) (built: Nov 20 2009 17:26:32) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies # echo "<?php set_include_path('.'.PATH_SEPARATOR.'./folder'); include('file.php'); ?>" > bug.php # dir ---[ output begin ]--- 07/03/2011 08:55 PM <DIR> . 07/03/2011 08:55 PM <DIR> .. 07/03/2011 08:53 PM 83 bug.php 1 File(s) 83 bytes 2 Dir(s) ---[ output end ]--- # php bug.php ---[ output begin ]--- Warning: include(file.php): failed to open stream: No such file or directory in C:\xampp\htdocs\test\cli_bug\bug.php on line 1 Warning: include(): Failed opening 'file.php' for inclusion (include_path='.;./folder') in C:\xampp\htdocs\test\cli_bug\bug.php on line 1 ---[ output end ]--- # mkdir folder # echo "INCLUDED FILE" > folder/file.php # php bug.php ---[ output begin ]--- ---[ output end ]--- # dir ---[ output begin ]--- 07/03/2011 08:54 PM <DIR> . 07/03/2011 08:54 PM <DIR> .. 07/03/2011 08:53 PM 83 bug.php 07/03/2011 08:54 PM 0 file.php 07/03/2011 08:54 PM <DIR> folder 2 File(s) 83 bytes 3 Dir(s) 612,782,497,792 bytes free ---[ output end ]---