http_build_query() With An Object Is Deprecated
http_build_query() accepts an object as its $data argument and builds the query string from its public properties. Until PHP 8.6, this was silently accepted. In PHP 8.6, passing an object emits a deprecation notice recommending get_object_vars() first; the resulting query string is unchanged.
PHP code
<?php
class Data {
public $a = 1;
public $b = 2;
}
var_dump(http_build_query(new Data()));
?>
Before
string(7) "a=1&b=2"
After
PHP Deprecated: http_build_query(): Passing an object for argument #1 $data to http_build_query() is deprecated, call get_object_vars() first instead in /codes/httpBuildQueryObjectDeprecated86.php on line 8
Deprecated: http_build_query(): Passing an object for argument #1 $data to http_build_query() is deprecated, call get_object_vars() first instead in /codes/httpBuildQueryObjectDeprecated86.php on line 8
string(7) "a=1&b=2"
PHP version change
This behavior was deprecated in 8.6.
This behavior changed in .