note 79846 added to function.return

From: Date: Sat, 15 Dec 2007 01:13:24 +0000
Subject: note 79846 added to function.return
Groups: php.notes 
Request: Send a blank email to php-notes+get-133487@lists.php.net to get a copy of this message
Salute, When an "included" script finishes executing and there is no return statement in the script, the returned value to the parent script is int(1), and not bool(true) Example 1: <?php # a.php $b= include_once( 'b.php' ); var_dump( $b ); # Outputs: int(1) 1 ?> <?php # b.php # This script is empty ?> If on the other hand you had an empty return statement in an "included" script, the returned value to the parent script is NULL Example 2: <?php # a.php $b= include_once( 'b.php' ); var_dump( $b ); # Outputs: NULL ?> <?php # b.php return; ?> And finally, Example 3: <?php # a.php $b= include_once( 'b.php' ); var_dump( $b ); # Outputs: int(1) 1 ?> <?php # b.php return 1; ?> This last example has the same output as Example 1. Something worth noting. Regards, drenintell ---- Server IP: 69.147.83.197 Probable Submitter: 99.229.228.119 ---- Manual Page -- http://www.php.net/manual/en/function.return.php Edit -- https://master.php.net/note/edit/79846 Del: integrated -- https://master.php.net/note/delete/79846/integrated Del: useless -- https://master.php.net/note/delete/79846/useless Del: bad code -- https://master.php.net/note/delete/79846/bad+code Del: spam -- https://master.php.net/note/delete/79846/spam Del: non-english -- https://master.php.net/note/delete/79846/non-english Del: in docs -- https://master.php.net/note/delete/79846/in+docs Del: other reasons-- https://master.php.net/note/delete/79846 Reject -- https://master.php.net/note/reject/79846 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#133487) next »