note 117928 added to curl.constants
| From: | uramihsayibok | Date: | Wed, 02 Sep 2015 21:07:56 +0000 |
| Subject: | note 117928 added to curl.constants | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203583@lists.php.net to get a copy of this message | ||
Regarding CURLE_OPERATION_TIMEDOUT vs. CURLE_OPERATION_TIMEOUTED:
Originally cURL had the constant named TIMEOUTED (read: "timeout-ed"). This was changed[1]
in 2007 and v7.17.0 to be TIMEDOUT (read: "timed out") and the old constant kept in place
as an alias.
PHP started off using TIMEOUTED as well. The TIMEDOUT constant was added[2] in 2012 and v5.5.0 and
the old constant was *kept in place*.
If you ask me, the TIMEDOUT constant reads more nicely (not to mention is technically the correct
one to use) and as long as you're using PHP 5.5+ then it is available. If you have to support
older versions then I suggest you keep using the new constant and add a polyfill like
<?php
if (version_compare(PHP_VERSION, "5.5.0", "<")) {
define("CURLE_OPERATION_TIMEDOUT", CURLE_OPERATION_TIMEOUTED);
}
?>
or
<?php
// PHP <5.5.0
defined("CURLE_OPERATION_TIMEDOUT") || define("CURLE_OPERATION_TIMEDOUT",
CURLE_OPERATION_TIMEOUTED);
?>
to be removed once you stop supporting them.
[1] https://github.com/bagder/curl/commit/9f44a95522162c0f4a61093efe1bf1f58b087358#diff-d8c6cb80505e0f7d5e27fca2a682aa34L119
[2] https://github.com/php/php-src/commit/9ab45d3edbafa3ee751472c3f8d1fb3f51f38cf1#diff-ac978e3de205f1d14eb960e0eb15ef24R723
----
Server IP: 72.52.91.14
Probable Submitter: 38.140.26.42
----
Manual Page -- http://php.net/manual/en/curl.constants.php
Edit -- https://master.php.net/note/edit/117928
Del: integrated -- https://master.php.net/note/delete/117928/integrated
Del: useless -- https://master.php.net/note/delete/117928/useless
Del: bad code -- https://master.php.net/note/delete/117928/bad+code
Del: spam -- https://master.php.net/note/delete/117928/spam
Del: non-english -- https://master.php.net/note/delete/117928/non-english
Del: in docs -- https://master.php.net/note/delete/117928/in+docs
Del: other reasons-- https://master.php.net/note/delete/117928
Reject -- https://master.php.net/note/reject/117928
Search -- https://master.php.net/manage/user-notes.php