Description
A simple curl() function. Call “curl(string $url);” and it returns the output of that URL (normally HTML) as a string.
Run
| View code [+] |
Create a snippet based on this »
View in new window »
<?php
function curl($url)
{
$user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1); // Fail on errors
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_PORT, 80); //Set the port number
curl_setopt($ch, CURLOPT_TIMEOUT, 15); // times out after 15s
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
return curl_exec($ch);
}
?>
Comments (2) | View comments for all versions (2)
jeff (author) said: 16 May
Also see curl_login(), a version which allows you to access pages behind a login.
wow gold said: 20 Sep
I play wow in 3 years and i know some wow gold,I love wow gold.
Log in if you have a Kogbox account.