|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32657 return statements in includes from a method always return null
Submitted: 2005-04-10 18:44 UTC Modified: 2005-04-10 22:31 UTC
From: LoN_Kamikaze at gmx dot de Assigned:
Status: Not a bug Package: Output Control
PHP Version: 5.0.4 OS: WinXP SP2
Private report: No CVE-ID: None
 [2005-04-10 18:44 UTC] LoN_Kamikaze at gmx dot de
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:
class testReturn {
 public test() {
  return 'there has been no return statement';
$test = new testReturn();

return 'Test return statement.';

Expected result:
Test return statement.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-10 18:52 UTC] LoN_Kamikaze at gmx dot de
Line 9 of the index.php reproduce code has of course to be
echo $test->test();
 [2005-04-10 20:29 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

 [2005-04-10 22:22 UTC] LoN_Kamikaze at gmx dot de
If it is not a bug, shouldn't return cause an error? It's a bug one way or another.
 [2005-04-10 22:31 UTC]
You return from the included script not from    
testReturn::test(). Please ask further support   
questions in the support forums/lists...  
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun May 28 05:03:46 2023 UTC