|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-11-08 23:24 UTC] vrana@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 20 11:00:02 2025 UTC |
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