php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #36612 implode of a object array don't call __toString()
Submitted: 2006-03-04 19:57 UTC Modified: 2006-03-04 20:10 UTC
Votes:4
Avg. Score:4.2 ± 0.4
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:2 (66.7%)
From: tobias dot buschor at relationpage dot ch Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 5.1.* OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-03-04 19:57 UTC] tobias dot buschor at relationpage dot ch
Description:
------------
I think it's better, if the implode() function call the __toString() method of a array width objects.

Reproduce code:
---------------
class obj{
  function __construct($name){
    $this->name = $name;
  }
  function __toString(){
    return $this->name;
  }
}

$arry = array();
$arry[] = new obj('first');
$arry[] = new obj('second');
$arry[] = new obj('onemore');

echo implode(', ', $arry);

Expected result:
----------------
first, second, onemore

Actual result:
--------------
Object, Object, Object

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-04 20:10 UTC] helly@php.net
Won't change in 5.1, aybe in 5.2 and already fixed in head (to become 6)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 28 02:01:31 2024 UTC