note 105977 deleted from function.return by danbrown

From: Date: Thu, 29 Sep 2011 18:59:17 +0000
Subject: note 105977 deleted from function.return by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-183528@lists.php.net to get a copy of this message
Note Submitter: siehtnix ---- @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.

« previous php.notes (#183528) next »