|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17720 "Cannot redeclare function_name previously declared in ..." is bogus
Submitted: 2002-06-11 21:48 UTC Modified: 2002-07-01 15:38 UTC
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: bdgridly at mailbolt dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.2.1 OS: Win2k and Apache
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
38 - 21 = ?
Subscribe to this entry?

 [2002-06-11 21:48 UTC] bdgridly at mailbolt dot com
It is possible in PHP 4.2.1 to confuse the interpreter into thinking a function had been previously declared when in
fact it is the same function. I'm sure this used to work in PHP 4.01. I installed 4.2.1 today and now it complains.

Sample test program:



function SystemTest()  //<<-- Error: SystemTest() previously declared in Main.Php at line 4
function NewTest()
    echo "New Test";

File: Test1.PHP
function test1()
    echo "This is Test1()<BR>";

If you run Main.PHP, it will generate an error because it thinks SystemTest was previously declared and it gives
as the line number of the "other" definition as the line # where the error occurred. So it is really pointing to itself.

In this simple example I could get rid of the "include_once("main.php")" and it will start to work. But what if Test1 is also called from test2.php. Then SystemTest() it won't find NewTest() that is in Main.Php.

Can this be fixed? TIA

Brent (e-mail me if you can with an explanation if it is operator error<g>)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-12 09:18 UTC]
include_once() is the problem here. It should propably
not include the current script run..

 [2002-06-12 10:31 UTC] bdgridly at mailbolt dot com
>include_once() is the problem here. It should propably
>not include the current script run.

Yes, the "include_once("main.php")" is causing the problem
because it confuses the interpreter into thinking SystemTest() is declared twice. If I remove the "include_once("main.php")", it will work. But this is a workaround.

What happens if test1() is also called from test2.php? How is test1() going to load NewTest() in main.php if there
is no include for main.php?

I am pretty sure this worked in PHP 4.06 because it stopped working yesterday when I installed PHP 4.2.1. The only way I see of correcting it is to go back to 4.06. :(
 [2002-06-23 21:11 UTC] phpbugs at soupisgoodfood dot network
I'm also experiencing this problem. 

I have tried to rearange things thinking it was my code 
(I'm a newbie).

All scripts for this particular site have one include() 
with functions decalred inside. Some have 2 includes with 
functions declared. They all work fine.

For some reason, one script with 2 includes for functions 
is giving this error (it's template is different). I still 
can't figure out what's causing it. 
But what's even stranger is, if I re-arrange one include 
(put it at the top, which shouldn't cause any problems) my 
browser gives me a "Attempt to load URL:foobar failed" 
error instead of PHP giving me the "Cannot redeclare..." 
error. PHP and Apatche carry on just fine on other pages 
after this happens (IE, it isn't crashing anything).

If anyone finds out more about this, I'd really appeciate 
it if you could contact my ASAP (don't forget to change the 
.network to .net on my address). Thanks.

 [2002-06-26 06:24 UTC] per_hekansson at hermes dot ics dot lu dot se
I have had a similar problem. I think it has to do with case sensitivity in the include once function. The inclusion is not case sensitive but the check if the script is allready included is.

The file name was
include_once("sql\"); -- no problem
include_once("sql\"); -- error

 [2002-06-29 00:06 UTC] bdgridly at mailbolt dot com
>>I have had a similar problem. I think it has to do with >>case sensitivity in the include once function. 

I tried your suggestion on my test files. I made the file names lowercase in the directory, and made the file names lowercase in the include_once() parameter. I also made the function names lowercase. It still fails with the same error message. Either way, it looks like a bug, walks like a bug, and bites like a bug. :{

I'm using PHP 4.2.1 on Win2k with Apache.
 [2002-06-30 09:38 UTC]
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at In case this was a documentation 
problem, the fix will show up soon at
In case this was a website problem, the change will show
up on the site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.

 [2002-07-01 15:38 UTC] bdgridly at mailbolt dot com
>>This bug has been fixed in CVS.
Great. Thanks. You guys work fast. :)

So what did I win for finding the bug? A coffee mug?
A T-Shirt that says "My PHP can beat your ASP?"
A new Boxster would be nice.:)
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Mar 02 12:01:23 2021 UTC