PHP curl

/**
 * @param string $link 请求的链接
 * @param string $method 请求的类型(get/post)
 * @param array $data post请求,提交的数据
 * @param int $content 是否将结果转换成字符串
 * @param int $header 是否显示报头
 * @return mixed 如果$content为1反回字符串,为0则直接执行
 */
function curl($link = '', $method = 'get', $data = array(), $content = 1, $header = 0) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $link);
    curl_setopt($ch, CURLOPT_HEADER, $header);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, $content);
    if ($method == 'post') {
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    }
    $output = curl_exec($ch);
    curl_close($ch);
    if ($content == 1) return $output;
}

$result = curl('https://www.baidu.com/', 'get', array(), 1, 0);
echo $result;