Kristian
Kristian

Reputation: 21810

programmatically check for CURLOPT_CONNECTTIMEOUT_MS before using curl_setopt

I know how to check if classes exists, and functions, but not if an option exists

the option: CURLOPT_CONNECTTIMEOUT_MS

In the documentation it says:

Added in cURL 7.16.2. Available since PHP 5.2.3.

So, there is an incentive to check before using it.

Upvotes: 0

Views: 146

Answers (1)

dev-null-dweller
dev-null-dweller

Reputation: 29462

It is a constant, so just check if it was defined:

if(defined('CURLOPT_CONNECTTIMEOUT_MS')) {

}

However, even if it defined, it doesn't mean it will work. See curl timeout less than 1000ms always fails? for more details.

Upvotes: 1

Related Questions