2013-01-25 23:50:06 0 Comments PHP Boy.Lee

CURL demo code

Curl is a very powerful php grab tool, can help grab everything. If u want grab something in php, just try the follow code

 

		$url = 'yiilib.com';  //url
		$ch = curl_init(); //init

		curl_setopt ($ch, CURLOPT_URL, $url); //add url
		curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); //do not direct render return data, save it to a varibale
		curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,10); //outtime control

		$content = curl_exec($ch); //run curl
		$result=json_decode($content); //get result and use json decode