What are the different methods, such as fopen() or curl, that can be used to read external pages in PHP?

To read external pages in PHP, you can use methods like fopen() or curl. These functions allow you to open a connection to a remote server and retrieve the contents of a webpage.

// Using fopen()
$handle = fopen("http://www.example.com", "r");
if ($handle) {
    while (!feof($handle)) {
        $buffer = fgets($handle, 4096);
        echo $buffer;
    }
    fclose($handle);
}

// Using curl
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.example.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);

echo $output;