How can relative path resources like links and images be properly handled when displaying external content on a webpage using PHP?

When displaying external content on a webpage using PHP, relative path resources like links and images may not work correctly due to the differences in file structures between the external content and the hosting server. To properly handle this, you can use PHP's `base64_encode` function to encode the external content and then decode it to display on the webpage. This way, all resources will be embedded within the HTML content and relative paths will work as expected.

<?php
// URL of the external content
$url = 'https://www.example.com/content.html';

// Get the content of the external URL
$content = file_get_contents($url);

// Encode the content using base64
$encoded_content = base64_encode($content);

// Display the decoded content on the webpage
echo '<div>' . base64_decode($encoded_content) . '</div>';
?>