What are the differences between using "rawurlencode" and "rawurldecode" in PHP, and when should each be used?

The "rawurlencode" function in PHP is used to encode a URL string by replacing special characters with their hexadecimal representation. On the other hand, "rawurldecode" is used to decode a URL string that has been previously encoded using "rawurlencode". It is important to use "rawurlencode" when encoding URLs that may contain special characters, and "rawurldecode" when decoding these URLs back to their original form.

// Encoding a URL string using rawurlencode
$url = "https://www.example.com/page.php?name=John Doe";
$encoded_url = rawurlencode($url);
echo $encoded_url;

// Decoding a previously encoded URL string using rawurldecode
$decoded_url = rawurldecode($encoded_url);
echo $decoded_url;