cvs: phpdoc /en/reference/curl/functions curl-errno.xml curl-error.xml curl-getinfo.xml curl-version.xml

From: Date: Wed, 01 Oct 2008 08:29:12 +0000
Subject: cvs: phpdoc /en/reference/curl/functions curl-errno.xml curl-error.xml curl-getinfo.xml curl-version.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-2173@lists.php.net to get a copy of this message
kalle Wed Oct 1 08:29:12 2008 UTC Modified files: /phpdoc/en/reference/curl/functions curl-errno.xml curl-error.xml curl-getinfo.xml curl-version.xml Log: Added new examples to CURL: - curl_errno() - curl_error() - curl_getinfo() - curl_version() http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/curl/functions/curl-errno.xml?r1=1.8&r2=1.9&diff_format=u Index: phpdoc/en/reference/curl/functions/curl-errno.xml diff -u phpdoc/en/reference/curl/functions/curl-errno.xml:1.8 phpdoc/en/reference/curl/functions/curl-errno.xml:1.9 --- phpdoc/en/reference/curl/functions/curl-errno.xml:1.8 Wed Jun 20 22:24:17 2007 +++ phpdoc/en/reference/curl/functions/curl-errno.xml Wed Oct 1 08:29:12 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.8 $ --> +<!-- $Revision: 1.9 $ --> <refentry xml:id='function.curl-errno' xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>curl_errno</refname> @@ -33,6 +33,36 @@ occurred. </para> </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>curl_errno</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Create a curl handle to a non-existing location +$ch = curl_init('http://404.php.net/'); + +// Execute +curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); +curl_exec($ch); + +// Check if any error occured +if(curl_errno($ch)) +{ + echo 'Curl error: ' . curl_error($ch); +} + +// Close handle +curl_close($ch); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> <refsect1 role="seealso"> &reftitle.seealso; http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/curl/functions/curl-error.xml?r1=1.8&r2=1.9&diff_format=u Index: phpdoc/en/reference/curl/functions/curl-error.xml diff -u phpdoc/en/reference/curl/functions/curl-error.xml:1.8 phpdoc/en/reference/curl/functions/curl-error.xml:1.9 --- phpdoc/en/reference/curl/functions/curl-error.xml:1.8 Wed Jun 20 22:24:17 2007 +++ phpdoc/en/reference/curl/functions/curl-error.xml Wed Oct 1 08:29:12 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.8 $ --> +<!-- $Revision: 1.9 $ --> <refentry xml:id='function.curl-error' xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>curl_error</refname> @@ -33,6 +33,36 @@ error occurred. </para> </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>curl_error</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Create a curl handle to a non-existing location +$ch = curl_init('http://404.php.net/'); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + +if(curl_exec($ch) === false) +{ + echo 'Curl error: ' . curl_error($ch); +} +else +{ + echo 'Operation completed without any errors'; +} + +// Close handle +curl_close($ch); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> <refsect1 role="seealso"> &reftitle.seealso; http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/curl/functions/curl-getinfo.xml?r1=1.15&r2=1.16&diff_format=u Index: phpdoc/en/reference/curl/functions/curl-getinfo.xml diff -u phpdoc/en/reference/curl/functions/curl-getinfo.xml:1.15 phpdoc/en/reference/curl/functions/curl-getinfo.xml:1.16 --- phpdoc/en/reference/curl/functions/curl-getinfo.xml:1.15 Fri Aug 3 05:15:16 2007 +++ phpdoc/en/reference/curl/functions/curl-getinfo.xml Wed Oct 1 08:29:12 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.15 $ --> +<!-- $Revision: 1.16 $ --> <refentry xml:id='function.curl-getinfo' xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>curl_getinfo</refname> @@ -247,6 +247,37 @@ </itemizedlist> </para> </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>curl_getinfo</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +// Create a curl handle to a non-existing location +$ch = curl_init('http://www.yahoo.com/'); + +// Execute +curl_exec($ch); + +// Check if any error occured +if(!curl_errno($ch)) +{ + $info = curl_getinfo($ch); + + echo 'Took ' . $info['total_time'] . ' seconds to send a request to ' . $info['url']; +} + +// Close handle +curl_close($ch); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> </refentry> <!-- Keep this comment at the end of the file http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/curl/functions/curl-version.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/curl/functions/curl-version.xml diff -u phpdoc/en/reference/curl/functions/curl-version.xml:1.7 phpdoc/en/reference/curl/functions/curl-version.xml:1.8 --- phpdoc/en/reference/curl/functions/curl-version.xml:1.7 Wed Jun 20 22:24:18 2007 +++ phpdoc/en/reference/curl/functions/curl-version.xml Wed Oct 1 08:29:12 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <refentry xml:id="function.curl-version" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>curl_version</refname> @@ -80,6 +80,44 @@ </informaltable> </para> </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>curl_version</function> example</title> + <para> + This example will check which features thats available + in cURL build by using the 'features' bitmask returned + by <function>curl_version</function>. + </para> + <programlisting role="php"> +<![CDATA[ +<?php +// Get curl version array +$version = curl_version(); + +// These are the bitfields that can be used +// to check for features in the curl build +$bitfields = Array( + 'CURL_VERSION_IPV6', + 'CURL_VERSION_KERBEROS4', + 'CURL_VERSION_SSL', + 'CURL_VERSION_LIBZ' + ); + + +foreach($bitfields as $feature) +{ + echo $feature . ($version['features'] & constant($feature) ? ' matches' : ' does not match'); + echo PHP_EOL; +} +?> +]]> + </programlisting> + </example> + </para> + </refsect1> </refentry> <!-- Keep this comment at the end of the file

« previous php.doc.cvs (#2173) next »