mirror of
https://github.com/php/doc-es.git
synced 2026-03-26 00:12:06 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@300142 c90b9560-bf6c-de11-be94-00142212c4b1
151 lines
4.0 KiB
XML
151 lines
4.0 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!-- EN-Revision: fb382072791be80401170b0da410934b1659599e Maintainer: yago Status: ready -->
|
|
<!-- $Revision$ -->
|
|
<refentry xml:id="function.curl-setopt-array" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>curl_setopt_array</refname>
|
|
<refpurpose>Configura múltiples opciones para una transferencia cURL</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>curl_setopt_array</methodname>
|
|
<methodparam><type>resource</type><parameter>ch</parameter></methodparam>
|
|
<methodparam><type>array</type><parameter>options</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Configura multiples opciones para una sesión cURL. Esta función
|
|
es muy útil para configurar gran cantidad de opciones cURL sin tener
|
|
que llamar cada vez <function>curl_setopt</function>.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
&curl.ch.description;
|
|
<varlistentry>
|
|
<term><parameter>opciones</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Un <type>array</type> especificando que opciones a configurar y con que valores.
|
|
Las keys deben contener constantes <function>curl_setopt</function> válidas o
|
|
sus integer equivalentes.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Devuelve &true; si todas las opciones se configuraron satisfactoriamente. Si una
|
|
opción no se pudo configurar devolverá &false; inmediatamente. Ignorando cualquier
|
|
otra opción en el array de <parameter>opciones</parameter>.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>
|
|
Iniciando una nueva sesión cURL y capturando una página web
|
|
</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// Crea un nuevo recurso cURL
|
|
$ch = curl_init();
|
|
|
|
// set URL and other appropriate options
|
|
$options = array(CURLOPT_URL => 'http://www.example.com/',
|
|
CURLOPT_HEADER => false
|
|
);
|
|
|
|
curl_setopt_array($ch, $options);
|
|
|
|
// grab URL and pass it to the browser
|
|
curl_exec($ch);
|
|
|
|
// close cURL resource, and free up system resources
|
|
curl_close($ch);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Anterior a PHP 5.1.3 esta función puede ser simulada con:
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>O nuestra implementación de <function>curl_setopt_array</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
if (!function_exists('curl_setopt_array')) {
|
|
function curl_setopt_array(&$ch, $curl_options)
|
|
{
|
|
foreach ($curl_options as $option => $value) {
|
|
if (!curl_setopt($ch, $option, $value)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<para>
|
|
Igual que <function>curl_setopt</function>, si se pasa un array a
|
|
<constant>CURLOPT_POST</constant> codificará los datos como
|
|
<emphasis>multipart/form-data</emphasis>, mientras que si pasa una
|
|
cadena URL-encoded codificará los datos como
|
|
<emphasis>application/x-www-form-urlencoded</emphasis>.
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>curl_setopt</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|