Get and output the source of the homepage of a website in PHP

Description

The following code shows how to get and output the source of the homepage of a website.

Example


/*from w  w w . j  a va  2s . c o m*/
<?php
$homepage = file_get_contents('http://www.java2s.com/');
echo $homepage;
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    File »




Directory
DirectoryIterator
Drive
File
File Permission
File Read Save
FileSystemIterator
Path
Zip