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
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.
(description)
Block user comment
Status: Assign to:
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

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: Sun May 19 10:01:32 2024 UTC