PHP 4.0 Bug #9884 Updated: Using a return in an included file causes a major abnormality.
| From: | ceo at phester dot org | Date: | Wed, 21 Mar 2001 01:00:02 +0000 |
| Subject: | PHP 4.0 Bug #9884 Updated: Using a return in an included file causes a major abnormality. | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-49572@lists.php.net to get a copy of this message | ||
ID: 9884
User Update by: ceo@phester.org
Status: Open
Bug Type: Scripting Engine problem
Description: Using a return in an included file causes a major abnormality.
Sorry, i forgot to include the output of test.php, here' you go:
----output----
Hi From weird.inc... 1
Previous Comments:
---------------------------------------------------------------------------
[2001-03-20 19:45:13] ceo@phester.org
According to documentation and common sense, using a return inside an include, should end processing
on the include and return to processing the script that called it. This is NOT so when functions or
classes are declared AFTER the return line. The Following example shows 2 very stange abnormalities
and it applies to functions aswell as classes...
1. functions/classes can still be declared AFTER the return line. The Declared function can be
executed.
2. If The funtion/class is declared TWICE, it does not print an error. (this hold true to any sort
of parse error, except errors withing the classes or functions =)
Here's the sample files:
---wierd.inc---
<?
return "Hi From wierd.inc...";
// The following should not even be processed...
function hello() {
global $inc_var;
echo $inc_var." 1";
}
// redeclaring the function should produce an error message
function hello() {
global $inc_var;
echo $inc_var." 2";
}
?>
---test.php---
<?
$inc_var = include("weird.inc");
// According the the documentation,
// this function should not exist..
hello();
?>
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=9884