From:             Christian dot Lefebvre at atosorigin dot com
Operating system: linux
PHP version:      5.0.0RC1
PHP Bug Type:     Scripting Engine problem
Bug description:  function redeclared when return before its declaration

Description:
------------
lot of php3 codes begin include files by a

  if(defined(..)) return; define(..)

to simulate include_once behavior



it works fine with php4, but with php5, functions

declared after this return raise "cannot redeclare" error

when the file is included twice.



Reproduce code:
---------------
t1.php :

<?php

include("t2.php");

toto();

include("t2.php");

toto();

?>



t2.php :

<?php

error_log("in t2");



if (defined("_T2_INCLUDED")) {

  error_log("already went there");

  return;

}

define("_T2_INCLUDED", "1");



error_log("still in t2");



function toto() {

  echo "Here am I !!\n";

}

?>



Expected result:
----------------
with php4 :

in t2

still in t2

Here am I !!

in t2

already went there

Here am I !!



Actual result:
--------------
with php5 :

in t2

still in t2

Here am I !!



Fatal error: Cannot redeclare toto() (previously declared in t2.php:13) in
t2.php on line 14



-- 
Edit bug report at http://bugs.php.net/?id=28025&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28025&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28025&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28025&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28025&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28025&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28025&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28025&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28025&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28025&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28025&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28025&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28025&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28025&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28025&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28025&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28025&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28025&r=float

Reply via email to