|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #27564 list behavior
Submitted: 2004-03-11 04:49 UTC Modified: 2004-03-11 05:24 UTC
From: bolk at hitv dot ru Assigned:
Status: Wont fix Package: Documentation problem
PHP Version: 4.3.4 OS: Windows ME
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: bolk at hitv dot ru
New email:
PHP Version: OS:


 [2004-03-11 04:49 UTC] bolk at hitv dot ru
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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-11 05:15 UTC]
It's a side affect, I don't think we should document this :-) (Also, don't rely on this behavior)
 [2004-03-11 05:24 UTC] bolk at hitv dot ru
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.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Feb 25 09:01:26 2024 UTC