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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tobias dot buschor at relationpage dot ch
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 09:01:32 2025 UTC