Doc #66966 [Com]: __toString not call by http_build_query

[email protected] ("fashionblogglobal at gmail dot com") Sat, 06 May 2023 06:21:23 +0000
Newsgroups php.doc.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=66966&edit=1

 ID:                 66966
 Comment by:         fashionblogglobal at gmail dot com
 Reported by:        dev dot php at ange7 dot com
 Summary:            __toString not call by http_build_query
 Status:             Verified
 Type:               Documentation Problem
 Package:            URL related
 Operating System:   *
 PHP Version:        5.6.9
 Block user comment: N
 Private report:     N

 New Comment:

Global Fashion Blog are out fashion, lifestyle, shopping, clothing, beauty, food, wedding etc. More info to visit: (https://globalfashionblog.com)github.com


Previous Comments:
------------------------------------------------------------------------
[2015-05-24 14:09:45] [email protected]

After having had a closer look at the implementation and the
documentation of http_build_query(), the behavior is not a bug,
but rather by design. The query string is build from arrays as
well as objects *recursively*. Example #4[1] demonstrates how that
works for nested objects.

Changing the behavior would be too much of a BC break for a small
gain (avoiding the manual cast to string). The documentation could
be improved however, to point out the behavior more clearly.
Therefore I'm changing to "Documentation problem".

[1] <http://php.net/manual/en/function.http-build-query.php#example-4523>

------------------------------------------------------------------------
[2015-05-24 13:47:50] [email protected]

I can confirm the behavior: <http://3v4l.org/16dMa>. However, I'm
not sure whether this qualifies as bug in PHP (it seems to be more
like a feature request).

Anyhow, you could simply cast the object to string manually, see
<http://3v4l.org/eMb8J>.

------------------------------------------------------------------------
[2014-07-28 07:39:35] martijn dot otto at copernica dot com

Is there any progress information available for this bug? It's pretty annoying since it means you always have to roll your own alternative to http_build_query.

------------------------------------------------------------------------
[2014-06-24 15:07:09] dev dot php at ange7 dot com

Nobody has any interest about this bug...?

------------------------------------------------------------------------
[2014-03-27 12:40:37] dev dot php at ange7 dot com

same bug with PHP 5.4.4-14+deb7u8

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=66966


--
Edit this bug report at https://bugs.php.net/bug.php?id=66966&edit=1