php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24671 Case problem with internal list of included files handling
Submitted: 2003-07-16 02:45 UTC Modified: 2003-07-16 02:48 UTC
From: stefan dot priebsch at e-novative dot de Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.3.2 OS: Win2K, WinXP
Private report: No CVE-ID: None
 [2003-07-16 02:45 UTC] stefan dot priebsch at e-novative dot de
Description:
------------
When the same file is include_once'd multiple times, but with a different case, PHP does not recognize that actually the same file is included multiple times. This can lead to "cannot redefine function (resp. class)" errors.

From looking at the array returned by get_included_files, it seems that PHP handles the list in a case-sensitive way, which obviously is wrong since Win path and file names are not case sensitive.

To reproduce the error, create main.php and include.php using the code below. The example produces a "cannot redefine" error, which is unexpected behaviour.

When commenting out the function definition and running the example again, one can see that the included file name appears twice in the list, but with different case.

Reproduce code:
---------------
main.php:

  print 'main ';
  
  include_once ('include.php');
  print_r (get_included_files ());
  
  include_once ('Include.php');
  print_r (get_included_files ());

include.php:

  print 'included file ';

  function included_fn ()
  {
    print 'included fn ';
  } 


Expected result:
----------------
main included file Array ( [0] => main.php [1] => include.php ) included file 

[full paths removed for clarity]

Actual result:
--------------
main included file Array ( [0] => main.php [1] => include.php ) included file 
Fatal error: Cannot redeclare included_fn() (previously declared in include.php:7) in Include.php on line 5

[full paths removed for clarity]

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-16 02:48 UTC] derick@php.net
Not a bug, as this is supposed to work on Unices like this.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 18 20:01:27 2024 UTC