php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6440 cannot redeclare function
Submitted: 2000-08-30 09:44 UTC Modified: 2000-08-30 09:57 UTC
From: ce at beer dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.2 OS: Linux Apache
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ce at beer dot com
New email:
PHP Version: OS:

 

 [2000-08-30 09:44 UTC] ce at beer dot com
this is test.php file

<?

for ($cnt = 0; $cnt<5; ++$cnt){

	require("test.inc.php");

	a($cnt);
}

echo "ok";
?>

-----------

and here is 

<?

function a($cnt){
	echo $cnt;
	return;
}

?>

----

the result is

0
Fatal error: Cannot redeclare a() in Unknown on line 3
-------
it is not necessary a bug since if the require is replaced by the code itself it gives the same error. But why the behavior is changed, in previous versions it works

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-30 09:49 UTC] stas@php.net
This is the intended behaviour.
 [2000-08-30 09:57 UTC] waldschrott@php.net
read the manual about require() and include() and why it
makes absolutely no sense to put this file in a loop whether
with require() or include()

once a function is declared you can use it how often you
want to, move that require() berfore that loop
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Dec 21 11:00:02 2025 UTC