|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28591 using an object as a string parameter converts it to a string
Submitted: 2004-05-31 11:50 UTC Modified: 2005-01-09 14:10 UTC
Avg. Score:4.0 ± 1.4
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:2 (66.7%)
From: lapo at lapo dot it Assigned:
Status: Closed Package: Tidy (PECL)
PHP Version: 5.0.0RC2 OS: Win32
Private report: No CVE-ID: None
 [2004-05-31 11:50 UTC] lapo at lapo dot it
Tidy-PHP binding documentation is not very clear (yep, I will RTFS someday) but in each example uses the output $tidy object directly in an "echo" just to output it's value, using (I guess) it's internal __toString() method.
As far as I do "echo" it, no problem, but passing it to a string-accepting function actually converts it to a string instead of just using the output of its toString method.

Reproduce code:
$tidy = tidy_parse_string('<b>Just a try', array(), 'UTF8');
$a = htmlspecialchars($tidy . '');
echo gettype($tidy) . ', ';
$a = htmlspecialchars($tidy);
echo gettype($tidy);

Expected result:
Output: object, object

Actual result:
Output: object, string


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-09 14:10 UTC]
This is already solved (at least in PHP 5.1).
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Mar 04 10:01:27 2024 UTC