What are the advantages and disadvantages of using http_build_query() compared to manually constructing query strings in PHP?

When constructing query strings in PHP, using the http_build_query() function can simplify the process by automatically encoding the data in the correct format. This can save time and reduce the risk of errors in constructing query strings manually. However, manually constructing query strings gives more control over the formatting and allows for customization that may not be possible with http_build_query().

// Using http_build_query() to construct a query string
$data = array(
    'name' => 'John Doe',
    'age' => 30,
    'city' => 'New York'
);

$queryString = http_build_query($data);

echo $queryString;