Open
Description
Description
The following code:
<?php
$params = [
'param1' => 1,
'param2' => new Class {
public function __toString():string {return 'test';}
}
];
echo http_build_query($params);
foreach ($params as $k => &$v) $params[$k] = (string) $v;
echo http_build_query($params);
Resulted in this output:
param1=1
But I expected this output instead:
param1=1¶m2=test
... as __toString() should have been implicitly called on the object. The ugly manual conversion shouldn't be necessary.
PHP Version
PHP 8.1
Operating System
Any