What is the correct way to embed a composite URL code in an iframe using PHP?

When embedding a composite URL code in an iframe using PHP, it is important to properly encode the URL to ensure it is correctly interpreted by the browser. This can be achieved using the `urlencode()` function in PHP. By encoding the URL before embedding it in the iframe code, you can prevent any issues related to special characters or spaces in the URL.

<?php
$compositeUrl = "http://example.com/page?param1=value1&param2=value2";
$encodedUrl = urlencode($compositeUrl);
?>
<iframe src="<?php echo $encodedUrl; ?>" width="100%" height="500px"></iframe>