Forum Moderators: coopster

Message Too Old, No Replies

PHP curl help

         

andrewsmd

2:01 pm on Nov 24, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So I just got curl installed and I am trying to store the HTML of a web page into a string. i.e. The user is on somepage.php and I generate a link but I want that links html to be a string and still keep the user's current page open. I need to search the HTML for various kinds of code before I redirect there. So far I have this.

$ch = curl_init();
$test = curl_setopt($ch, CURLOPT_RETURNTRANSFER, "http://www.somepage.com");
var_dump($test);

I get a bool(true) so I know it's working but how do I get the actual HTML of the page. Thanks,

Receptional Andy

2:12 pm on Nov 24, 2008 (gmt 0)



You don't have your curl syntax correct. A simplified example would be:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://www.somepage.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
[3]$html=curl_exec($ch);[/3]
curl_close($ch);

andrewsmd

2:44 pm on Nov 24, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That worked. Thanks,