#32657 [NEW]: return statements in includes from a method always return null
| From: | LoN_Kamikaze at gmx dot de | Date: | Sun, 10 Apr 2005 16:44:11 +0000 |
| Subject: | #32657 [NEW]: return statements in includes from a method always return null | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-76592@lists.php.net to get a copy of this message | ||
From: LoN_Kamikaze at gmx dot de
Operating system: WinXP SP2
PHP version: 5.0.4
PHP Bug Type: Output Control
Bug description: return statements in includes from a method always return null
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 bug report at http://bugs.php.net/?id=32657&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32657&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32657&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32657&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=32657&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=32657&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=32657&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=32657&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=32657&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=32657&r=support
Expected behavior: http://bugs.php.net/fix.php?id=32657&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=32657&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=32657&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=32657&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32657&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=32657&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=32657&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=32657&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=32657&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=32657&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=32657&r=mysqlcfg