What are the best practices for handling URL parameters in PHP to ensure compatibility with different browsers and server setups?

When handling URL parameters in PHP, it's important to properly sanitize and validate the input to prevent security vulnerabilities and ensure compatibility with different browsers and server setups. One way to do this is by using the filter_input() function to retrieve and sanitize the URL parameters.

// Retrieve and sanitize URL parameter
$param = filter_input(INPUT_GET, 'param', FILTER_SANITIZE_STRING);

// Check if parameter is present and not empty
if(isset($param) && !empty($param)){
    // Use the sanitized parameter in your code
    echo "Parameter value: " . $param;
} else {
    // Handle case when parameter is missing or empty
    echo "Parameter is missing or empty";
}