3v4l.org

run code in 300+ PHP versions simultaneously
<?php $params = [ 'param1' => 1, 'param2' => new Class { public function __toString():string {return 'test';} } ]; echo http_build_query($params) . PHP_EOL; foreach ($params as $k => &$v) $params[$k] = (string) $v; echo http_build_query($params) . PHP_EOL;
Output for 8.1.23 - 8.1.33, 8.2.1 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
param1=1 param1=1&param2=test

preferences:
74.58 ms | 406 KiB | 5 Q