php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42314 bug in function declaration
Submitted: 2007-08-16 02:14 UTC Modified: 2007-08-19 22:08 UTC
From: ramymb at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.2.3 OS: windows 2003
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: ramymb at gmail dot com
New email:
PHP Version: OS:

 

 [2007-08-16 02:14 UTC] ramymb at gmail dot com
Description:
------------
OS: windows 2003 + IIS
PHP Version: 5.2.3

when I'm declare my own function myFun in a file func.php, I'm included into my main index.php, it's working at first time without any problem, when I'm using current page to submit data into the same page I'm getting the following error:

Fatal error: Cannot redeclare myfun() (previously declared in C:\accounts\panela\tmp\func.php:2) in C:\accounts\panela\tmp\func.php on line 2

I don't know whats the problem, I'm tried to solve this problem but I'm failed :(
this error is not logic, and the same script working in other php version like php 4.X


Reproduce code:
---------------
--- file: func.php ---
<?
function myFun($a,$b){ return $a+$b; }
?>

--- file: index.php ---
<?
include_once("func.php");
?>
<form name="FormName" action="" method="post">
	<input type="submit" value="Send">
</form>


Expected result:
----------------
this code when submit data into same php page.
I'm solved this problem by:


<?
if (!function_exists('myFun')) {                 
   function myFun($a,$b){ return $a+$b; }
}
?>

but unfortunately, when I'm refreshing the page I'm cant see my last editing in my function, for example, now I will edit the function to:

<?
if (!function_exists('myFun')) {                 
   function myFun($a,$b){ return $a*$b; }
}
?>
now with function_exists I cant see the new function $a*$b, but I'm see only the old function $a-$b.



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-18 18:56 UTC] ramymb at gmail dot com
Dear sir, I'm emailed the support, and support answered me:
> Please try http://snaps.php.net/win32/php5.2-win32-installer-latest.msi
> If you can still reproduce this after installing this snapshot then
> please file a bug report at http://bugs.php.net/report.php
> 
> -Hannes

please try by yourself to use the simplest code:

<?
function test(){ return 2; }
echo '<form name="FormName" action="" method="post">
<input type="submit" value="Send">
</form>';
?>

you must have the msg:
>> Fatal error: Cannot redeclare test() (previously declared in C:\accounts\panela\tmp\bug.php:2) in C:\accounts\panela\tmp\index.php on line 2

I'm sure it's a bug I'm professional user of php.

Thanks

Ramy
 [2007-08-19 20:02 UTC] jani@php.net
Don't redeclare test()..simple as that.
 [2007-08-19 22:08 UTC] ramymb at gmail dot com
this problem is happen with any really function. you can test any function.

Thanks

Ramy
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sun Apr 12 21:00:02 2026 UTC