Files
php-doc-ru/reference/curl/examples.xml
Sergey Panteleev daef8df962 Обнуление тега Reviewed (#364)
[skip-lint]
[skip-spellcheck]
2021-11-16 13:03:53 +03:00

65 lines
2.2 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 217fa0d006cf292e837bab6458b81341718eb35e Maintainer: shein Status: ready -->
<!-- Reviewed: no -->
<chapter xml:id="curl.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.examples;
<section xml:id="curl.examples-basic">
<title>Простой пример использования curl</title>
<para>
Как только вы собрали PHP с поддержкой cURL уже можно
использовать функции cURL. Работа с cURL всегда начинается с
вызова <function>curl_init</function>, затем устанавливаются
необходимые параметры с помощью <function>curl_setopt</function>,
и выполняется требуемая операция вызовом <function>curl_exec</function>,
после чего вызовом <function>curl_close</function> сеанс работы
завершается.
Приведённый ниже пример использует функции cURL для сохранения
стартовой страницы сайта example.com в файл:
<example>
<title>Использование модуля cURL для сохранения стартовой страницы example.com</title>
<programlisting role="php">
<![CDATA[
<?php
$ch = curl_init("http://www.example.com/");
$fp = fopen("example_homepage.txt", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
if(curl_error($ch)) {
fwrite($fp, curl_error($ch));
}
curl_close($ch);
fclose($fp);
?>
]]>
</programlisting>
</example>
</para>
</section>
</chapter>
<!-- 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
-->