PHP: curl_init – Manual

“`php
$opts = 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(‘foo’=>’bar’))
  )
);

$context = stream_context_create($opts);

$fp = fopen(‘

“`

This stream support can also be accessed using the object-oriented interface of SplFileObject.

On recent distributions CURL and PHP support for CURL have not been included in the main product. In particular in recent distributions of Ubuntu Linux CURL and PHP support for CURL are not even available from the official repositories. The steps to incorporate support are complex and require adding a non-standard repository. It is therefore advisable for programmers to rewrite code to use the stream interface to access resources across the Internet. For example:“`php$opts = 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(‘foo’=>’bar’)));$context = stream_context_create($opts);$fp = fopen(‘ https://www.example.com ‘, ‘r’, false, $context);“`This stream support can also be accessed using the object-oriented interface of SplFileObject.