PHP Knowledge Base

file_get_contents

Example 1

Code

<?php
$url = "https://bettermousetraps.net/bio.html";

$biopage__src = file_get_contents($url);
echo $biopage__src;
?>

Output

Bio

Bio

Name: Dave
Age: 46
Height: 5'8"
Weight: 180 lbs.

* Page would output with all the linebreaks of the original file intact and the php echo command would cause browser to render the page.

Example 2 1

$url = 'https://www.php.net';
$html = file_get_contents($url);
file_put_contents('home.html', $html);