php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #30723 Multiple incude()'s of file with func defs incorrectly documented for PHP 4
Submitted: 2004-11-08 22:39 UTC Modified: 2004-11-08 23:24 UTC
From: php dot devel at homelinkcs dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Mandrake Linux 10.0
Private report: No CVE-ID: None
 [2004-11-08 22:39 UTC] php dot devel at homelinkcs dot com
Description:
------------
The documentation page for the include() construct states  
that:   
  
"If there are functions defined in the included file, they  
can be used in the main file independent if they are  
before return() or after. If the file is included twice,  
PHP 5 issues fatal error because functions were already  
declared, while PHP 4 doesn't complain about it."  
  
However, PHP 4 _does_ "complain" (which it should) about  
it as demonstrated below.  Therefore, I believe the second  
sentence in the quote above should read, "If the file is  
included twice, a  fatal error is issued because functions  
were already declared."  
  
  

Reproduce code:
---------------
a.php:
<?php
        include("b.php");
        include("b.php");
?>

b.php:
<?php
        function foo() {
                echo "I've been included!\n";
        }
?>

Running a.php, PHP 4.3.4 dies with:
Fatal error: Cannot redeclare foo() (previously declared in /tmp/b.php:3) in /tmp/b.php on line 2



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-11-08 23:24 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"about it" means "about functions defined after return".
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 03:01:33 2025 UTC