note 105977 added to function.return

From: Date: Thu, 29 Sep 2011 14:13:54 +0000
Subject: note 105977 added to function.return
Groups: php.notes 
Request: Send a blank email to php-notes+get-183525@lists.php.net to get a copy of this message
@Radu 1) Your script won't print anything because you don't call any of your functions. 2) The results aren't unexpected. Not a little bit. It has nothing to do with the array declaration. Function a() only returns element 'e' of the array. Why should anybody expect to get the whole array? It makes no sense. <?php function a() { return $a['e'] = 'sometxt'; } function b() { $a['e'] = 'sometxt'; return $b = $a; } function c() { if(is_array(a())) { echo 'a is array'; }else{ echo 'a is NOT an array'; } if(is_array(b())) { echo 'b is array'; }else{ echo 'b is NOT an array'; } } c(); ?> $b will be returned as array without previous declaration. ---- Server IP: 69.147.83.197 Probable Submitter: 217.231.48.247 ---- Manual Page -- http://www.php.net/manual/en/function.return.php Edit -- https://master.php.net/note/edit/105977 Del: integrated -- https://master.php.net/note/delete/105977/integrated Del: useless -- https://master.php.net/note/delete/105977/useless Del: bad code -- https://master.php.net/note/delete/105977/bad+code Del: spam -- https://master.php.net/note/delete/105977/spam Del: non-english -- https://master.php.net/note/delete/105977/non-english Del: in docs -- https://master.php.net/note/delete/105977/in+docs Del: other reasons-- https://master.php.net/note/delete/105977 Reject -- https://master.php.net/note/reject/105977 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#183525) next »