Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 2446

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Initialize a cURL session</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.curl-getinfo.html">curl_getinfo</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.curl-multi-add-handle.html">curl_multi_add_handle</a></div>
 <div class="up"><a href="ref.curl.html">cURL Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><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>
 
 <div class="refsect1 description" id="refsect1-function.curl-init-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">resource</span> <span class="methodname"><strong>curl_init</strong></span>
    ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$url</code><span class="initializer"> = <strong><code>NULL</code></strong></span></span>
  ] )</div>

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


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

    <dt>

     <span class="term"><em><code class="parameter">url</code></em></span>
     <dd>

      <p class="para">
       If provided, the <strong><code>CURLOPT_URL</code></strong> option will be set
       to its value. You can manually set this using the 
        <span class="function"><a href="function.curl-setopt.html" class="function">curl_setopt()</a></span> function.
      </p>
      <blockquote class="note"><p><strong class="note">Note</strong>: 
       <p class="para">
        The <em>file</em> protocol is disabled by cURL if
        <a href="ini.core.html#ini.open-basedir" class="link">open_basedir</a> is set.
       </p>
      </p></blockquote>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


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

 
 <div class="refsect1 examples" id="refsect1-function.curl-init-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-4215">
    <p><strong>Example #1 
     Initializing a new cURL session and fetching a web page
    </strong></p>
    <div class="example-contents">
<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>
 </div>


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


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.curl-getinfo.html">curl_getinfo</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.curl-multi-add-handle.html">curl_multi_add_handle</a></div>
 <div class="up"><a href="ref.curl.html">cURL Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>