file_get_contents( - Fix relative urls
问题 I am trying to display a website to a user, having downloaded it using php. This is the script I am using: <?php $url = 'http://stackoverflow.com/pagecalledjohn.php'; //Download page $site = file_get_contents($url); //Fix relative URLs $site = str_replace('src="','src="' . $url,$site); $site = str_replace('url(','url(' . $url,$site); //Display to user echo $site; ?> So far this script works a treat except for a few major problems with the str_replace function. The problem comes with relative