Author: Tim Düsterhus (TimWolla)
Committer: GitHub (web-flow)
Pusher: Crell
Date: 2025-10-20T09:44:36-05:00
Commit: https://github.com/php/doc-en/commit/fc9a0a8b29a7a099998bdd71fe5350a10b18fe62
Raw diff: https://github.com/php/doc-en/commit/fc9a0a8b29a7a099998bdd71fe5350a10b18fe62.diff
curl: Remove curl_close()
from all examples (#4941)
* curl: Remove curl_close()
from all examples
* curl: Remove curl_share_close()
from all examples
Changed paths:
M reference/curl/curlfile/construct.xml
M reference/curl/examples.xml
M reference/curl/functions/curl-copy-handle.xml
M reference/curl/functions/curl-errno.xml
M reference/curl/functions/curl-error.xml
M reference/curl/functions/curl-escape.xml
M reference/curl/functions/curl-exec.xml
M reference/curl/functions/curl-getinfo.xml
M reference/curl/functions/curl-multi-close.xml
M reference/curl/functions/curl-reset.xml
M reference/curl/functions/curl-setopt-array.xml
M reference/curl/functions/curl-setopt.xml
M reference/curl/functions/curl-share-close.xml
M reference/curl/functions/curl-share-init.xml
M reference/curl/functions/curl-share-setopt.xml
M reference/curl/functions/curl-strerror.xml
M reference/curl/functions/curl-unescape.xml
M reference/curl/functions/curl-upkeep.xml
Diff:
diff --git a/reference/curl/curlfile/construct.xml b/reference/curl/curlfile/construct.xml
index d2b0eac8789f..89e80a2cf159 100644
--- a/reference/curl/curlfile/construct.xml
+++ b/reference/curl/curlfile/construct.xml
@@ -180,8 +180,6 @@ curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($request);
var_dump(curl_getinfo($request));
-
-curl_close($request);
]]>
</programlisting>
<para>&style.procedural;</para>
@@ -202,8 +200,6 @@ curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($request);
var_dump(curl_getinfo($request));
-
-curl_close($request);
]]>
</programlisting>
&example.outputs;
diff --git a/reference/curl/examples.xml b/reference/curl/examples.xml
index 71d6f7847110..e657ee9eb71d 100644
--- a/reference/curl/examples.xml
+++ b/reference/curl/examples.xml
@@ -12,8 +12,7 @@
<function>curl_init</function>, then you can set all your
options for the transfer via the <function>curl_setopt</function>,
then you can execute the session with the
- <function>curl_exec</function> and then you finish off
- your session using the <function>curl_close</function>.
+ <function>curl_exec</function>.
Here is an example that uses the cURL functions to fetch the
example.com homepage into a file:
<example>
@@ -32,7 +31,6 @@ curl_exec($ch);
if(curl_error($ch)) {
fwrite($fp, curl_error($ch));
}
-curl_close($ch);
fclose($fp);
?>
]]>
@@ -63,4 +61,3 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
-
diff --git a/reference/curl/functions/curl-copy-handle.xml
b/reference/curl/functions/curl-copy-handle.xml
index b16ebdd793eb..9d479e11627c 100644
--- a/reference/curl/functions/curl-copy-handle.xml
+++ b/reference/curl/functions/curl-copy-handle.xml
@@ -77,10 +77,6 @@ $ch2 = curl_copy_handle($ch);
// grab URL (http://www.example.com/) and pass it to the browser
curl_exec($ch2);
-
-// close cURL resources, and free up system resources
-curl_close($ch2);
-curl_close($ch);
?>
]]>
</programlisting>
diff --git a/reference/curl/functions/curl-errno.xml b/reference/curl/functions/curl-errno.xml
index 7e2608dd39bc..b34a1881752d 100644
--- a/reference/curl/functions/curl-errno.xml
+++ b/reference/curl/functions/curl-errno.xml
@@ -71,9 +71,6 @@ if(curl_errno($ch))
{
echo 'Curl error: ' . curl_error($ch);
}
-
-// Close handle
-curl_close($ch);
?>
]]>
</programlisting>
diff --git a/reference/curl/functions/curl-error.xml b/reference/curl/functions/curl-error.xml
index 68b527de95fe..30b4e6fa68e7 100644
--- a/reference/curl/functions/curl-error.xml
+++ b/reference/curl/functions/curl-error.xml
@@ -71,9 +71,6 @@ else
{
echo 'Operation completed without any errors';
}
-
-// Close handle
-curl_close($ch);
?>
]]>
</programlisting>
diff --git a/reference/curl/functions/curl-escape.xml b/reference/curl/functions/curl-escape.xml
index b4077c02f87f..3ee6d7ef2459 100644
--- a/reference/curl/functions/curl-escape.xml
+++ b/reference/curl/functions/curl-escape.xml
@@ -81,7 +81,6 @@ $url = "http://example.com/add_location.php?location={$location}";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
-curl_close($ch);
?>
]]>
</programlisting>
diff --git a/reference/curl/functions/curl-exec.xml b/reference/curl/functions/curl-exec.xml
index d8bc9532e3d8..c8d01d945f08 100644
--- a/reference/curl/functions/curl-exec.xml
+++ b/reference/curl/functions/curl-exec.xml
@@ -83,9 +83,6 @@ curl_setopt($ch, CURLOPT_HEADER, 0);
// grab URL and pass it to the browser
curl_exec($ch);
-
-// close cURL resource, and free up system resources
-curl_close($ch);
?>
]]>
</programlisting>
diff --git a/reference/curl/functions/curl-getinfo.xml b/reference/curl/functions/curl-getinfo.xml
index 0d4e8269fe46..8ef530385967 100644
--- a/reference/curl/functions/curl-getinfo.xml
+++ b/reference/curl/functions/curl-getinfo.xml
@@ -277,9 +277,6 @@ if (!curl_errno($ch)) {
$info = curl_getinfo($ch);
echo 'Took ', $info['total_time'], ' seconds to send a request to
', $info['url'], "\n";
}
-
-// Close handle
-curl_close($ch);
?>
]]>
</programlisting>
@@ -306,9 +303,6 @@ if (!curl_errno($ch)) {
echo 'Unexpected HTTP code: ', $http_code, "\n";
}
}
-
-// Close handle
-curl_close($ch);
?>
]]>
</programlisting>
diff --git a/reference/curl/functions/curl-multi-close.xml
b/reference/curl/functions/curl-multi-close.xml
index 0351a20b91ac..6be6f9099b45 100644
--- a/reference/curl/functions/curl-multi-close.xml
+++ b/reference/curl/functions/curl-multi-close.xml
@@ -59,7 +59,6 @@
<para>
<simplelist>
<member><function>curl_multi_init</function></member>
- <member><function>curl_close</function></member>
</simplelist>
</para>
</refsect1>
diff --git a/reference/curl/functions/curl-reset.xml b/reference/curl/functions/curl-reset.xml
index 7fc0a89453eb..36849d7a0854 100644
--- a/reference/curl/functions/curl-reset.xml
+++ b/reference/curl/functions/curl-reset.xml
@@ -69,9 +69,6 @@ curl_reset($ch);
// Send HTTP request
curl_setopt($ch, CURLOPT_URL, 'http://example.com/');
curl_exec($ch); // the previously set user-agent will be not sent, it has been reset by curl_reset
-
-// Close the handle
-curl_close($ch);
?>
]]>
</programlisting>
diff --git a/reference/curl/functions/curl-setopt-array.xml
b/reference/curl/functions/curl-setopt-array.xml
index 22b4174c7a5d..a52b171179d7 100644
--- a/reference/curl/functions/curl-setopt-array.xml
+++ b/reference/curl/functions/curl-setopt-array.xml
@@ -86,9 +86,6 @@ 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>
diff --git a/reference/curl/functions/curl-setopt.xml b/reference/curl/functions/curl-setopt.xml
index bea2c818411b..0ea60e36df5d 100644
--- a/reference/curl/functions/curl-setopt.xml
+++ b/reference/curl/functions/curl-setopt.xml
@@ -154,9 +154,6 @@ curl_setopt($ch, CURLOPT_HEADER, false);
// grab URL and pass it to the browser
curl_exec($ch);
-
-// close cURL resource, and free up system resources
-curl_close($ch);
?>
]]>
</programlisting>
diff --git a/reference/curl/functions/curl-share-close.xml
b/reference/curl/functions/curl-share-close.xml
index a9ede12fec25..372d744196fd 100644
--- a/reference/curl/functions/curl-share-close.xml
+++ b/reference/curl/functions/curl-share-close.xml
@@ -88,10 +88,6 @@ curl_exec($ch2);
// Close the cURL share handle
curl_share_close($sh);
-
-// Close the cURL handles
-curl_close($ch1);
-curl_close($ch2);
?>
]]>
</programlisting>
diff --git a/reference/curl/functions/curl-share-init.xml
b/reference/curl/functions/curl-share-init.xml
index c3e8884e330f..54ca7e829301 100644
--- a/reference/curl/functions/curl-share-init.xml
+++ b/reference/curl/functions/curl-share-init.xml
@@ -83,13 +83,6 @@ curl_setopt($ch2, CURLOPT_SHARE, $sh);
// Execute the second cURL handle
// all cookies from $ch1 handle are shared with $ch2 handle
curl_exec($ch2);
-
-// Close the cURL share handle
-curl_share_close($sh);
-
-// Close the cURL handles
-curl_close($ch1);
-curl_close($ch2);
?>
]]>
</programlisting>
@@ -102,7 +95,6 @@ curl_close($ch2);
<para>
<simplelist>
<member><function>curl_share_setopt</function></member>
- <member><function>curl_share_close</function></member>
<member><function>curl_share_init_persistent</function></member>
</simplelist>
</para>
diff --git a/reference/curl/functions/curl-share-setopt.xml
b/reference/curl/functions/curl-share-setopt.xml
index 27a859d1714b..13bebddd5e33 100644
--- a/reference/curl/functions/curl-share-setopt.xml
+++ b/reference/curl/functions/curl-share-setopt.xml
@@ -97,13 +97,6 @@ curl_setopt($ch2, CURLOPT_SHARE, $sh);
// Execute the second cURL handle
// all cookies from $ch1 handle are shared with $ch2 handle
curl_exec($ch2);
-
-// Close the cURL share handle
-curl_share_close($sh);
-
-// Close the cURL handles
-curl_close($ch1);
-curl_close($ch2);
?>
]]>
</programlisting>
diff --git a/reference/curl/functions/curl-strerror.xml b/reference/curl/functions/curl-strerror.xml
index e4a8d406c089..6cacec3ac0a3 100644
--- a/reference/curl/functions/curl-strerror.xml
+++ b/reference/curl/functions/curl-strerror.xml
@@ -58,9 +58,6 @@ if($errno = curl_errno($ch)) {
$error_message = curl_strerror($errno);
echo "cURL error ({$errno}):\n {$error_message}";
}
-
-// Close the handle
-curl_close($ch);
?>
]]>
</programlisting>
diff --git a/reference/curl/functions/curl-unescape.xml b/reference/curl/functions/curl-unescape.xml
index f115711c002f..93214b6faa1f 100644
--- a/reference/curl/functions/curl-unescape.xml
+++ b/reference/curl/functions/curl-unescape.xml
@@ -79,9 +79,6 @@ $effective_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
// Decode the URL
$effective_url_decoded = curl_unescape($ch, $effective_url);
// "http://example.com/show_location.php?loc=München"
-
-// Close the handle
-curl_close($ch);
?>
]]>
</programlisting>
diff --git a/reference/curl/functions/curl-upkeep.xml b/reference/curl/functions/curl-upkeep.xml
index fea892030a23..1de13be862f3 100644
--- a/reference/curl/functions/curl-upkeep.xml
+++ b/reference/curl/functions/curl-upkeep.xml
@@ -62,7 +62,6 @@ if (curl_exec($ch)) {
usleep(300);
var_dump(curl_upkeep($ch));
}
-curl_close($ch);
?>
]]>
</programlisting>