#32657 [Opn]: return statements in includes from a method always return null
| From: | LoN_Kamikaze at gmx dot de | Date: | Sun, 10 Apr 2005 16:52:16 +0000 |
| Subject: | #32657 [Opn]: return statements in includes from a method always return null | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-76593@lists.php.net to get a copy of this message | ||
ID: 32657
User updated by: LoN_Kamikaze at gmx dot de
Reported By: LoN_Kamikaze at gmx dot de
Status: Open
Bug Type: Output Control
Operating System: WinXP SP2
PHP Version: 5.0.4
New Comment:
Line 9 of the index.php reproduce code has of course to be
echo $test->test();
Previous Comments:
------------------------------------------------------------------------
[2005-04-10 18:44:10] LoN_Kamikaze at gmx dot de
Description:
------------
As the PHP Documentation says:
"When a file is included, the code it contains inherits the variable
scope of the line on which the include occurs. Any variables available
at that line in the calling file will be available within the called
file, from that point forward."
From this I take that if an include occurs in a method, the included
script should be able to use a return statement. Doing this terminates
the method, but the returned value is always null.
Reproduce code:
---------------
index.php
<?php
class testReturn {
public test() {
include('test.php');
return 'there has been no return statement';
}
}
$test = new testReturn();
$test->test();
?>
test.php
<?php
return 'Test return statement.';
?>
Expected result:
----------------
Test return statement.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=32657&edit=1