Protocol https not supported or disabled in libcurl

Have you ever seen this error before when working with CURL:

“Protocol https not supported or disabled in libcurl”

Yet, you know that https works. Or even:

“Protocol http not supported or disabled in libcurl”

And you think, “What the hell? That’s basically what CURL is for. Why would HTTP not work!?”

Try wrapping that echoed out error message with <pre> tags:

Protocol  https not supported or disabled in libcurl

Notice anything?

There is an extra space before ‘https’. Make sure that when you do set CURLOPT_URL, you don’t put a space before the http, CURL won’t know what to do with it.

PHP And Nesting Ternary Operators

I came across an interesting quirk in PHP today. The way a nested ternary operator is evaluated in PHP is unlike that of any other language I’ve come across: left to right.

Ex:

<?php
$test = 'one';
echo $test == 'one' ? 'one' :  $test == 'two' ? 'two' : 'three';
?>

What do you suppose that prints? Wrong, the answer is ‘two’. Let’s break this down in how it is working, shall we.

<?php
$test = 'one';
echo $test == 'one' ? 'one' :  $test == 'two' ? 'two' : 'three';
?>

Here, I’ve emphasized the first ternary operation. What PHP will do is evaluate this section and return a value, in this case it is the string ‘one’. The boolean value of the string ‘one’ is true. So, for the second ternary operation, ‘two’ gets selected.

No other language I know of acts like this.

Hopes this help someone one day.