faqts : Computers : Programming : Languages : PHP : Sample Code

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

7 of 10 people (70%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How can I load the HTML file from a given URL into a php variable?

Sep 28th, 2006 13:29
Iman Moradi, Ken Loomis, http://www.higherpass.com/php/Tutorials/Using-Curl-To-Query-Remote-Servers/


I suggest you try the curl library.
A simple way of using it is listed below.



<?php

// initiate curl
$ch = curl_init();

// set options for curl session
curl_setopt($ch, CURLOPT_URL, 'http://www.google.com');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

// execute
$pagecontents= curl_exec($ch);
curl_close($ch);

//print out variable contents
echo($pagecontents);

?>