php cUrl错误初始化错误

I am trying to use curl and I thought this was built in to PHP for a long time.

But I am getting the following error Call to undefined function curl_init()

I copied this code from a ajax tutorial, could anyone point me in the right direction please.

 $url = $_POST['url'];
 unset($_POST['url']);
 $fields_string = "";
 //url-ify the data for the POST
 foreach($_POST as $key=>$value) {
     $fields_string .= $key.'='.$value.'&';
 }
 $fields_string = rtrim($fields_string,'&');
 //open connection
 $ch = curl_init();
 //set the url, number of POST vars, POST data
 curl_setopt($ch,CURLOPT_URL,$url);
 curl_setopt($ch,CURLOPT_POST,count($_POST));
 curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
 //execute post
 $result = curl_exec($ch);
 //close connection
 curl_close($ch);

Why don't you use file_get_contents instead of cURL ?

$url = (isset($_POST['url']) && is_string($_POST['url'])) ? $_POST['url'] : die('url parameter required.');
unset($_POST['url']);
$data = http_build_query($_POST, '', '&');
$result = file_get_contents($url, false, stream_context_create(array(
    'http' => array(
        'method' => 'POST',
        'header' => implode("
", array(
            'Content-Type: application/x-www-form-urlencoded',
            'Content-Length: ' . strlen($data),
        )),
        'content' => $data,
    ),
)));