downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/function.curl-init.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/ref.curl.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'function.curl-init.php',
   
1 => 'curl_init',
  ),
 
'up' =>
  array (
   
0 => 'ref.curl.php',
   
1 => 'cURL Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.curl-getinfo.php',
   
1 => 'curl_getinfo',
  ),
 
'next' =>
  array (
   
0 => 'function.curl-multi-add-handle.php',
   
1 => 'curl_multi_add_handle',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.curl-init" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">curl_init</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.2, PHP 5)</p><p class="refpurpose"><span class="refname">curl_init</span> &mdash; <span class="dc-title">Initialize a cURL session</span></p>

 </div>
 
 <a name="function.curl-init.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">resource</span> <span class="methodname"><b>curl_init</b></span>
    ([ <span class="methodparam"><span class="type">string</span> <tt class="parameter">$url</tt><span class="initializer"> = NULL</span></span>
  ] )</div>

  <p class="para rdfs-comment">
   Initializes a new session and return a cURL handle for use with the
   <a href="function.curl-setopt.php" class="function">curl_setopt()</a>, <a href="function.curl-exec.php" class="function">curl_exec()</a>,
   and <a href="function.curl-close.php" class="function">curl_close()</a> functions. 
  </p>
 </div>


 <a name="function.curl-init.parameters"></a><div class="refsect1 parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   </p><dl>

    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">url</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       If provided, the <b><tt class="constant">CURLOPT_URL</tt></b> option will be set
       to its value. You can manually set this using the
       <a href="function.curl-setopt.php" class="function">curl_setopt()</a> function.
      </p>
     </dd>

   
   </dl>
<p>
  </p>
 </div>


 <a name="function.curl-init.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns a cURL handle on success, <b><tt class="constant">FALSE</tt></b> on errors.
  </p>
 </div>

 
 <a name="function.curl-init.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   </p><div class="example">
    <p><b>Example #1
     Initializing a new cURL session and fetching a web page
    </b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;create&nbsp;a&nbsp;new&nbsp;cURL&nbsp;resource<br /></span><span style="color: #0000BB">$ch&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">curl_init</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">//&nbsp;set&nbsp;URL&nbsp;and&nbsp;other&nbsp;appropriate&nbsp;options<br /></span><span style="color: #0000BB">curl_setopt</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">CURLOPT_URL</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"http://www.example.com/"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">curl_setopt</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">CURLOPT_HEADER</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;grab&nbsp;URL&nbsp;and&nbsp;pass&nbsp;it&nbsp;to&nbsp;the&nbsp;browser<br /></span><span style="color: #0000BB">curl_exec</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;close&nbsp;cURL&nbsp;resource,&nbsp;and&nbsp;free&nbsp;up&nbsp;system&nbsp;resources<br /></span><span style="color: #0000BB">curl_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div><p>
  </p>
 </div>


 <a name="function.curl-init.seealso"></a><div class="refsect1 seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   </p><ul class="simplelist">
    <li class="member"><a href="function.curl-close.php" class="function" rel="rdfs-seeAlso">curl_close()</a> - Close a cURL session</li>
    <li class="member"><a href="function.curl-multi-init.php" class="function" rel="rdfs-seeAlso">curl_multi_init()</a> - Returns a new cURL multi handle</li>
   </ul><p>
  </p>
 </div>


</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites