What are the best practices for passing data in a URL in PHP?

When passing data in a URL in PHP, it is important to properly encode the data to prevent errors or security vulnerabilities. One common method is to use the `urlencode()` function to encode the data before appending it to the URL. This ensures that special characters are properly handled and the data is safely transmitted.

// Encode the data before passing it in the URL
$data = urlencode($data);
$url = "example.com/page.php?data=$data";

// To decode the data on the receiving end
$data = urldecode($_GET['data']);