Bug #67689 [NEW]: require_once and include_once both fail to recognize previously included file
| From: | albertnelsen at earthlink dot net | Date: | Sat, 26 Jul 2014 23:08:25 +0000 |
| Subject: | Bug #67689 [NEW]: require_once and include_once both fail to recognize previously included file | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-186825@lists.php.net to get a copy of this message | ||
From: albertnelsen at earthlink dot net
Operating system: Linux Debian Wheezy
PHP version: 5.5.15
Package: Scripting Engine problem
Bug Type: Bug
Bug description:require_once and include_once both fail to recognize previously included file
Description:
------------
I'm using:
PHP 5.5.15-1~dotdeb.1 (cli) (built: Jul 24 2014 16:44:04) on
Linux unmapped 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64 GNU/Linux
if you attempt to require_once or include_once the same file where the
path differs only by the use of backslashes instead of forward slashes,
PHP will attempt to include the file a second time.
Test script:
---------------
//Test1:
require_once "src/ClassA.php";
require_once "src/ClassA.php";
//Test2:
require_once "src\\ClassA.php";
require_once "src\\ClassA.php";
//Test3:
require_once "src/ClassA.php";
require_once "src\\ClassA.php";
//Test4:
require_once "src\\ClassA.php";
require_once "src/ClassA.php";
Expected result:
----------------
For this to work you need a file in the src/ClassA.php directory.
Preferably one that declares and defines the ClassA class.
Test1: This code should only include the file once and produce no
errors.
Test2: This code should only include the file once and produce no
errors.
Test3: This code should only include the file once and produce no
errors.
Test4: This code should only include the file once and produce no
errors.
Actual result:
--------------
Test1: This code only includes the file once and produces no errors.
Test2: This code only includes the file once and produces no errors.
Test3: This code attempts to include the file twice resulting in a
"Cannot redeclare class" error if the file contains a declaration of
ClassA.
Test4: This code attempts to include the file twice resulting in a
"Cannot redeclare class" error if the file contains a declaration of
ClassA.
--
Edit bug report at https://bugs.php.net/bug.php?id=67689&edit=1
--