|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-04-10 18:52 UTC] LoN_Kamikaze at gmx dot de
[2005-04-10 20:29 UTC] johannes@php.net
[2005-04-10 22:22 UTC] LoN_Kamikaze at gmx dot de
[2005-04-10 22:31 UTC] johannes@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 01:00:01 2025 UTC |
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.