What are the advantages and disadvantages of using http_build_query in PHP for generating URL-encoded query strings?

When generating URL-encoded query strings in PHP, using the http_build_query function can be advantageous as it simplifies the process by automatically encoding the data in the correct format. This function also handles special characters and arrays efficiently. However, one disadvantage is that it may not provide full control over the encoding process, which could be a limitation in certain scenarios.

// Example of using http_build_query to generate a URL-encoded query string
$data = array(
    'name' => 'John Doe',
    'age' => 30,
    'city' => 'New York'
);

$queryString = http_build_query($data);
echo $queryString;