|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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:
File: MAIN.PHP
<?PHP
include_once("test1.php");
function SystemTest() //<<-- Error: SystemTest() previously declared in Main.Php at line 4
{
Test1();
}
function NewTest()
{
echo "New Test";
}
SystemTest();
?>
File: Test1.PHP
<?PHP
include_once("main.php");
function test1()
{
echo "This is Test1()<BR>";
NewTest();
}
?>
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>)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 04:00:02 2025 UTC |
>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. :(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 sqlFunctions.inc include_once("sql\sqlFunctions.inc"); -- no problem include_once("sql\sqlfunctions.inc"); -- error /Perper, >>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.