<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = 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 => 'es',
  ),
  'this' => 
  array (
    0 => 'function.curl-exec.php',
    1 => 'curl_exec',
    2 => 'Ejecuta una sesi&oacute;n cURL',
  ),
  'up' => 
  array (
    0 => 'ref.curl.php',
    1 => 'Funciones de cURL',
  ),
  'prev' => 
  array (
    0 => 'function.curl-escape.php',
    1 => 'curl_escape',
  ),
  'next' => 
  array (
    0 => 'function.curl-getinfo.php',
    1 => 'curl_getinfo',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'es',
    'path' => 'reference/curl/functions/curl-exec.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.curl-exec" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">curl_exec</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.2, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">curl_exec</span> &mdash; <span class="dc-title">Ejecuta una sesión cURL</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.curl-exec-description">
  <h3 class="title">Descripción</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>curl_exec</strong></span>(<span class="methodparam"><span class="type"><a href="class.curlhandle.php" class="type CurlHandle">CurlHandle</a></span> <code class="parameter">$handle</code></span>): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></span></div>

  <p class="para rdfs-comment">
   Ejecuta la sesión cURL proporcionada.
  </p>
  <p class="para">
   Esta función debe llamarse después de inicializar una sesión cURL y de que todas
   las opciones de la sesión estén configuradas.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.curl-exec-parameters">
  <h3 class="title">Parámetros</h3>
  <p class="para">
   <dl>
    <dt><code class="parameter">handle</code>
</dt><dd><p class="para">Un gestor cURL devuelto por
<span class="function"><a href="function.curl-init.php" class="function">curl_init()</a></span>.</p></dd>
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.curl-exec-returnvalues">
  <h3 class="title">Valores devueltos</h3>
  <p class="para">
   En caso de éxito, esta función vacía el resultado directamente en
   <code class="literal">stdout</code> y devuelve <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>,  o <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> si ocurre un error.
   Sin embargo, si <strong><code><a href="curl.constants.php#constant.curlopt-returntransfer">CURLOPT_RETURNTRANSFER</a></code></strong>
   está <a href="function.curl-setopt.php" class="link">definida</a>, la función devolverá
   el resultado en caso de éxito, y <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> en caso de fallo.
  </p>
  <div class="warning"><strong class="warning">Advertencia</strong><p class="simpara">
 Esta función puede retornar <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>, pero también puede retornar un valor equivalente a <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
 Por favor, lea la sección sobre los <a href="language.types.boolean.php" class="link">booleanos</a> para más información.
 Utilice el <a href="language.operators.comparison.php" class="link">operador ===</a>
 para probar el valor de retorno exacto de esta función.
</p></div>
  <blockquote class="note"><p><strong class="note">Nota</strong>: 
   <p class="para">
    Tenga en cuenta que los códigos de estado de una respuesta que indican errores (como
    <code class="literal">404 Not found</code>) no se consideran fallos.
    <span class="function"><a href="function.curl-getinfo.php" class="function">curl_getinfo()</a></span> puede ser utilizado para verificar estos casos.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.curl-exec-changelog">
  <h3 class="title">Historial de cambios</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Versión</th>
      <th>Descripción</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.0.0</td>
 <td>
  <code class="parameter">handle</code> ahora espera una instancia de <span class="classname"><a href="class.curlhandle.php" class="classname">CurlHandle</a></span>;
  anteriormente, se esperaba un <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>.
 </td>
</tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.curl-exec-examples">
  <h3 class="title">Ejemplos</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Ejemplo #1 Recupera el contenido de una página web</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">// Creación de un nuevo recurso cURL<br /></span><span style="color: #0000BB">$ch </span><span style="color: #007700">= </span><span style="color: #0000BB">curl_init</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">// Configuración de la URL y otras opciones<br /></span><span style="color: #0000BB">curl_setopt</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch</span><span style="color: #007700">, </span><span style="color: #0000BB">CURLOPT_URL</span><span style="color: #007700">, </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">, </span><span style="color: #0000BB">CURLOPT_HEADER</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Recuperación de la URL y visualización en el navegador<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 /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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


 <div class="refsect1 seealso" id="refsect1-function.curl-exec-seealso">
  <h3 class="title">Ver también</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.curl-multi-exec.php" class="function" rel="rdfs-seeAlso">curl_multi_exec()</a> - Ejecuta las subpeticiones de la sesi&oacute;n cURL</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>