Is it best practice to use utf8_decode in a URL query string in PHP?

When passing non-ASCII characters in a URL query string in PHP, it is best practice to encode them using urlencode() to ensure they are properly handled. Using utf8_decode() is not recommended for this purpose as it is meant for decoding UTF-8 encoded strings, not encoding them for URLs. By using urlencode(), you can safely pass special characters in a URL query string without encountering issues.

// Encode non-ASCII characters in a URL query string using urlencode()
$param1 = urlencode('Déjà vu');
$param2 = urlencode('日本語');

// Construct the URL with the encoded parameters
$url = 'https://example.com/api?param1=' . $param1 . '&param2=' . $param2;

// Output the URL
echo $url;