Q:

Equivalent of PostMethod of Java in PHP

I would like to ask if there exists a PHP function to simulate this block of code in Codeigniter.
HttpClient httpClient       = new HttpClient();
PostMethod postMethod       = new PostMethod(requestURL);
NameValuePair[] datas       = {new NameValuePair("studentnumber", studentnumber), 
                              new NameValuePair("studentdata", encryptedData)};

postMethod.setRequestBody(datas);
int statusCode      = httpClient.executeMethod(postMethod);
byte[] responseByte = postMethod.getResponseBody();
String responseBody = new String(responseByte, "UTF-8");

curl doesn't seem to work, while $this->output->set_output passes the data properly but fails to catch the response of the requestUrl.
Thank you.

A:

I was able to catch the response from requestUrl using this block of code that I found on HTTP POST from PHP, without cURL (thanks a lot for this).
$options = array(
    'http' => array(
        'method' => "POST",
        'header' => "Accept-language: en\r\n" . "Content-type: application/x-www-form-urlencoded\r\n",
        'content' => http_build_query(array(
            'studentnumber' => $studentnumber,
            'studentdata' => $encryptedData,
        ),'','&'
    )
));

$refno = file_get_contents($requestUrl,false,$context);

