#27564 [WFx]: list behavior

From: Date: Thu, 11 Mar 2004 10:24:22 +0000
Subject: #27564 [WFx]: list behavior
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969359480@lists.php.net to get a copy of this message
ID: 27564 User updated by: bolk at hitv dot ru Reported By: bolk at hitv dot ru Status: Wont fix Bug Type: Documentation problem Operating System: Windows ME PHP Version: 4.3.4 New Comment: Funny side effect :)) By the way this behavior may cause some problem: function Test() { $res = some_user_func(); return count($res) == 1 ? $res[0] : $res; } list ($a) = Test(); If some_user_func returns "array(1,2)" then $a will contains '1' but if it returns array('Test') then $a will contains 'T'. I think it will be better if PHP cause notice or something in this way or make right type conversion. Previous Comments: ------------------------------------------------------------------------ [2004-03-11 05:15:06] derick@php.net It's a side affect, I don't think we should document this :-) (Also, don't rely on this behavior) ------------------------------------------------------------------------ [2004-03-11 04:49:35] bolk at hitv dot ru Description: ------------ This is correct but no record in documentation: $test = 'Test'; list ($a, $b) = $test; echo $a.$b; Reproduce code: --------------- $test = 'Test'; list ($a, $b) = $test; echo $a.$b; Expected result: ---------------- it prints: Te ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=27564&edit=1

« previous php.doc (#969359480) next »