Get the HTML source of PHP page after load

I’m sure I’ve seen someone post on here a few days ago to do something like

$url = "-insert-your-url-here";
$filename = "-insert-your-local-filename-here";
file_put_contents($filename, file_get_contents($url));

if you want to do it from PHP to a server.