Hello there,
PHP supports URL Wrappers - a way for you to use all the standard functions for opening files but for HTTP connections. If allow_url_fopen is enabled in your hosts php.ini file, you should be good to go. A simple phpinfo() call will show whether it is or not. Anyways, two examples (complicated and not complicated):
// Create a blank string, web_buffer
$web_buffer = "";
// Use fopen() to begin reading cnn.com
$web_site = fopen("http://www.cnn.com/", "r");
// While we are not at the end of the file of our file //pointer...
while (!feof($web_site)) {
// Append onto our string each line of the session
$web_buffer .= fgets($web_site,1024);
}
OR
//file_get_contents() does the above work for you
$cnn_com = file_get_contents("http://www.cnn.com");
As you get more experience you will learn the woes of reading large sets of data into a string, but for now it will work for you. 🙂
Cheers,
Ben