Bug #67689 [Opn]: require_once and include_once both fail to recognize previously included file
| From: | yohgaki@php.net | Date: | Mon, 28 Jul 2014 03:36:32 +0000 |
| Subject: | Bug #67689 [Opn]: require_once and include_once both fail to recognize previously included file | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-186832@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67689&edit=1
ID: 67689
Updated by: yohgaki@php.net
Reported by: albertnelsen at earthlink dot net
Summary: require_once and include_once both fail to recognize
previously included file
Status: Open
Type: Bug
Package: Scripting Engine problem
Operating System: Linux Debian Wheezy
PHP Version: 5.5.15
Block user comment: N
Private report: N
New Comment:
I got different results from 5.4/5.5/5.6 (all of them are git checkout) with Fedora 20 x86_64. Same
for fedora provided PHP 5.5. Debian might have patch for this.
Fatal error: require_once(): Failed opening required 'src\ClassA.php'
(include_path='.:/usr/local/php5.6/share/pear') in
/home/yohgaki/workspace/ext/git/oss/php.net/PHP-5.6/t.php on line 3
[yohgaki@dev PHP-5.6]$ cat t.php
<?php
require_once "src/ClassA.php";
require_once "src\\ClassA.php";
"/" works under Windows as well as "\\". Thus, users are recommended to use
"/" regardless of OS.
Are we going to fix this?
Previous Comments:
------------------------------------------------------------------------
[2014-07-26 23:08:24] albertnelsen at earthlink dot net
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 this bug report at https://bugs.php.net/bug.php?id=67689&edit=1