What is the correct way to include a URL variable in an iframe in PHP?

When including a URL variable in an iframe in PHP, it is important to properly encode the URL to prevent any issues with special characters. One way to achieve this is by using the `urlencode()` function in PHP to encode the URL variable before including it in the iframe src attribute.

<?php
// URL variable to be included in the iframe
$url = 'https://example.com/page.php?param1=value1&param2=value2';

// Encode the URL variable using urlencode()
$encoded_url = urlencode($url);
?>

<iframe src="<?php echo $encoded_url; ?>" width="100%" height="500"></iframe>