#33979 [Opn->Bgs]: require() language construct broken?
| From: | sniper@php.net | Date: | Wed, 03 Aug 2005 14:53:38 +0000 |
| Subject: | #33979 [Opn->Bgs]: require() language construct broken? | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-82890@lists.php.net to get a copy of this message | ||
ID: 33979
Updated by: sniper@php.net
Reported By: missingno at ifrance dot com
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: WinXP
PHP Version: 5.0.4
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
You get the expected behaviour by putting the function declaration in
maininc.php inside the if()..else() block:
<? // maininc.php
if ($myvar == 1) { require('sndinc.php'); return; }
else { function myfunc() { echo "Exec'ed from maininc.php!!"; }
}
?>
Previous Comments:
------------------------------------------------------------------------
[2005-08-03 15:34:51] missingno at ifrance dot com
Description:
------------
I think the require language construct may be broken in PHP 5.0.4 under
Windows/Apache2 as it seems to ignore return statements in conditionnal
blocks.
Note: if you set $myvar to 0 in the code, there's no such problem.
Reproduce code:
---------------
<? // testfile.php
$myvar = 1;
include('maininc.php');
myfunc();
?>
<? // maininc.php
if ($myvar == 1) { require('sndinc.php'); return; }
function myfunc() { echo "Exec'ed from maininc.php!!"; }
?>
<? // sndinc.php
function myfunc() { echo "Second included file..."; }
?>
Expected result:
----------------
I would expect the script to simply echo "Second included file..." and
terminate.
Actual result:
--------------
Fatal error: Cannot redeclare myfunc() (previously declared in
D:\HTTPd\www\tests\maininc.php:8) in D:\HTTPd\www\tests\sndinc.php on
line 5
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33979&edit=1