ID:               37030
 Updated by:       [EMAIL PROTECTED]
 Reported By:      stevenmoss at gmail dot com
 Status:           Bogus
 Bug Type:         Scripting Engine problem
 Operating System: Ubuntu 6.06
 PHP Version:      5.1.2
 New Comment:

http://php.net/include

Handling Returns: It is possible to execute a return() statement inside
an included file in order to terminate processing in that file and
return to the script which called it. Also, it's possible to return
values from included files. 

Try <?php echo require("ReturnTest.php"); ?>, you'll see what's this
all about.


Previous Comments:
------------------------------------------------------------------------

[2006-04-10 13:47:25] stevenmoss at gmail dot com

Thankyou for the swift response.

I must say I'm bewildered if this is the intended behaviour of PHP. 
Why would it be ok for PHP to treat all the code within an included
file as though it were within the including file EXCEPT for return
values?  The return statement DOES execute (I have other examples which
prove this), why then is it logical that it should not also return the
value assigned to it?

This is very important for me because I have large objects with many
functions which are difficult to manage unless split over many files. 
This behaviour would seem to make it impossible for me to do so.

P.S. I have read the relevant documentation for program structure and
the behaviour of include/require etc. before I submitted the bug report
and it seems to back me up.

Thanks,
S

------------------------------------------------------------------------

[2006-04-10 13:12:01] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php



------------------------------------------------------------------------

[2006-04-10 13:10:01] stevenmoss at gmail dot com

Description:
------------
This bug was first reported (coincidentally) exactly one year ago as
bug #32657 in Version 5.0.4, it was deemed bogus.  I believe that
judgement was in error.

Reproduce code:
---------------
"Test.php"
<?php
Class TestObject {
   function ReturnTest() {
      require("ReturnTest.php");
   }
}
$oTest = New TestObject();
Echo $oTest->ReturnTest();
?>

"ReturnTest.php"
<?php
return "Test";
?>

Expected result:
----------------
"Test" should be output

Actual result:
--------------
No output


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=37030&edit=1

Reply via email to