How can the callback_url function be optimized for better performance or readability in the PHP code snippet?

The callback_url function can be optimized for better performance and readability by using a more concise and clear way to concatenate the query parameters in the URL string. This can be achieved by using the http_build_query function in PHP, which automatically handles URL encoding and concatenation of query parameters.

function callback_url($url, $params) {
    $query = http_build_query($params);
    return $url . '?' . $query;
}

// Example usage
$url = "https://example.com/callback";
$params = array(
    'param1' => 'value1',
    'param2' => 'value2'
);

$callback_url = callback_url($url, $params);
echo $callback_url;