很多时候只需要一个简单的方法就可以了,无需引入很多第三方库,比如发送一个Get请求,简单又实用:
public static function send_get($urlstring) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $urlstring); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_REFERER, ""); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0"); $result = curl_exec($ch); curl_close($ch); return $result; }