|
| 1 | +<?xml version="1.0" encoding="utf-8"?><!-- EN-Revision: 01d19a544891db839e36de8316e78f81de56c1ca Maintainer: leonardolara Status: ready --><!-- CREDITS: leonardolara --> |
| 2 | +<refentry xml:id="function.curl-share-init-persistent" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> |
| 3 | + <refnamediv> |
| 4 | + <refname>curl_share_init_persistent</refname> |
| 5 | + <refpurpose>Inicializa um identificador compartilhado cURL <emphasis role="bold">persistente</emphasis></refpurpose> |
| 6 | + </refnamediv> |
| 7 | + |
| 8 | + <refsect1 role="description"> |
| 9 | + &reftitle.description; |
| 10 | + <methodsynopsis> |
| 11 | + <type>CurlSharePersistentHandle</type><methodname>curl_share_init_persistent</methodname> |
| 12 | + <methodparam><type>array</type><parameter>share_options</parameter></methodparam> |
| 13 | + </methodsynopsis> |
| 14 | + <simpara> |
| 15 | + Inicializa um identificador compartilhado cURL <emphasis role="bold">persistente</emphasis> |
| 16 | + com as opções de compartilhamento informadas. Diferente de <function>curl_share_init</function>, |
| 17 | + os identificadores criados por esta função não serão destruídos ao final da |
| 18 | + requisição PHP. Se um identificador compartilhado persistente com o mesmo conjunto de |
| 19 | + <parameter>share_options</parameter> for encontrado, ele será reutilizado. |
| 20 | + </simpara> |
| 21 | + </refsect1> |
| 22 | + |
| 23 | + <refsect1 role="parameters"> |
| 24 | + &reftitle.parameters; |
| 25 | + |
| 26 | + <variablelist> |
| 27 | + <varlistentry> |
| 28 | + <term><parameter>share_options</parameter></term> |
| 29 | + <listitem> |
| 30 | + <simpara> |
| 31 | + Um array não vazio de constantes <constant>CURL_LOCK_DATA_<replaceable>*</replaceable></constant>. |
| 32 | + </simpara> |
| 33 | + <note> |
| 34 | + <simpara> |
| 35 | + <constant>CURL_LOCK_DATA_COOKIE</constant> |
| 36 | + não é permitida e, se utilizada, esta função lançará uma exceção |
| 37 | + <exceptionname>ValueError</exceptionname>. Compartilhar cookies entre requisições |
| 38 | + PHP pode levar a uma mistura inadvertida de cookies sensíveis entre usuários. |
| 39 | + </simpara> |
| 40 | + </note> |
| 41 | + </listitem> |
| 42 | + </varlistentry> |
| 43 | + </variablelist> |
| 44 | + |
| 45 | + </refsect1> |
| 46 | + |
| 47 | + <refsect1 role="returnvalues"> |
| 48 | + &reftitle.returnvalues; |
| 49 | + <simpara> |
| 50 | + Retorna um objeto <classname>CurlSharePersistentHandle</classname>. |
| 51 | + </simpara> |
| 52 | + </refsect1> |
| 53 | + |
| 54 | + <refsect1 role="errors"> |
| 55 | + &reftitle.errors; |
| 56 | + <itemizedlist> |
| 57 | + <listitem> |
| 58 | + <simpara> |
| 59 | + Se <parameter>share_options</parameter> estiver vazio, esta função lança uma |
| 60 | + exceção <exceptionname>ValueError</exceptionname>. |
| 61 | + </simpara> |
| 62 | + </listitem> |
| 63 | + <listitem> |
| 64 | + <simpara> |
| 65 | + Se <parameter>share_options</parameter> contiver um valor que não corresponde |
| 66 | + a uma constante <constant>CURL_LOCK_DATA_<replaceable>*</replaceable></constant>, |
| 67 | + esta função lança uma exceção <classname>ValueError</classname>. |
| 68 | + </simpara> |
| 69 | + </listitem> |
| 70 | + <listitem> |
| 71 | + <simpara> |
| 72 | + Se <parameter>share_options</parameter> contiver |
| 73 | + <constant>CURL_LOCK_DATA_COOKIE</constant>, esta função lança uma exceção |
| 74 | + <exceptionname>ValueError</exceptionname>. |
| 75 | + </simpara> |
| 76 | + </listitem> |
| 77 | + <listitem> |
| 78 | + <simpara> |
| 79 | + Se <parameter>share_options</parameter> contiver um valor não inteiro, |
| 80 | + esta função lança uma exceção <exceptionname>TypeError</exceptionname>. |
| 81 | + </simpara> |
| 82 | + </listitem> |
| 83 | + </itemizedlist> |
| 84 | + </refsect1> |
| 85 | + |
| 86 | + <refsect1 role="examples"> |
| 87 | + &reftitle.examples; |
| 88 | + <example xml:id="function.curl-share-init-persistent.example.basic"> |
| 89 | + <title>Exemplo de <function>curl_share_init_persistent</function></title> |
| 90 | + <simpara> |
| 91 | + Este exemplo criará um identificador de compartilhamento cURL persistente e demonstrará |
| 92 | + conexões compartilhadas entre si. Se isso for executado em um PHP SAPI |
| 93 | + de longa duração, <literal>$sh</literal> sobreviverá entre as requisições SAPI. |
| 94 | + </simpara> |
| 95 | + |
| 96 | + <programlisting role="php"> |
| 97 | + <![CDATA[ |
| 98 | +<?php |
| 99 | +// Cria ou recupera um identificador de compartilhamento cURL persistente definido para compartilhar pesquisas e conexões de DNS. |
| 100 | +$sh = curl_share_init([CURL_LOCK_DATA_DNS, CURL_LOCK_DATA_CONNECT]); |
| 101 | +
|
| 102 | +// Inicializa o primeiro identificador cURL e atribui a ele o identificador de compartilhamento. |
| 103 | +$ch1 = curl_init("http://example.com/"); |
| 104 | +curl_setopt($ch1, CURLOPT_SHARE, $sh); |
| 105 | +
|
| 106 | +// Executa o primeiro identificador cURL. Isto pode reutilizar a conexão de uma solicitação SAPI anterior. |
| 107 | +curl_exec($ch1); |
| 108 | +
|
| 109 | +// Inicializa o segundo identificador cURL e atribui o identificador de compartilhamento a ele. |
| 110 | +$ch2 = curl_init("http://example.com/"); |
| 111 | +curl_setopt($ch2, CURLOPT_SHARE, $sh); |
| 112 | +
|
| 113 | +// Executa o segundo identificador cURL. Isso reutilizará a conexão de $ch1. |
| 114 | +curl_exec($ch2); |
| 115 | +
|
| 116 | +// Fecha os identificadores cURL |
| 117 | +curl_close($ch1); |
| 118 | +curl_close($ch2); |
| 119 | +?> |
| 120 | +
|
| 121 | + ]]> |
| 122 | + </programlisting> |
| 123 | + </example> |
| 124 | + </refsect1> |
| 125 | + |
| 126 | + <refsect1 role="seealso"> |
| 127 | + &reftitle.seealso; |
| 128 | + <simplelist> |
| 129 | + <member><function>curl_setopt</function></member> |
| 130 | + <member><function>curl_share_init</function></member> |
| 131 | + </simplelist> |
| 132 | + </refsect1> |
| 133 | + |
| 134 | +</refentry> |
| 135 | +<!-- Keep this comment at the end of the file |
| 136 | +Local variables: |
| 137 | +mode: sgml |
| 138 | +sgml-omittag:t |
| 139 | +sgml-shorttag:t |
| 140 | +sgml-minimize-attributes:nil |
| 141 | +sgml-always-quote-attributes:t |
| 142 | +sgml-indent-step:1 |
| 143 | +sgml-indent-data:t |
| 144 | +indent-tabs-mode:nil |
| 145 | +sgml-parent-document:nil |
| 146 | +sgml-default-dtd-file:"~/.phpdoc/manual.ced" |
| 147 | +sgml-exposed-tags:nil |
| 148 | +sgml-local-catalogs:nil |
| 149 | +sgml-local-ecat-files:nil |
| 150 | +End: |
| 151 | +vim600: syn=xml fen fdm=syntax fdl=2 si |
| 152 | +vim: et tw=78 syn=sgml |
| 153 | +vi: ts=1 sw=1 |
| 154 | +--> |
0 commit comments