Why does this curl_init php result enter false?

Asked

Viewed 58 times

0

I have the following script:

...    
$fields = http_build_query($data);
$post = curl_init();

$url = $url . '?' . $fields;
curl_setopt($post, CURLOPT_URL, $url);
curl_setopt($post, CURLOPT_POST, 1);
curl_setopt($post, CURLOPT_POSTFIELDS, $fields);

$result = curl_exec($post);

if ($result == false) {
    echo('Curl error: ' . curl_error($post));
}
var_dump($result);

curl_close($post);

I put the var_dump to see the result of $result. The result is bool(true)

Turns out he’s on the echo line

There on the server that receives the request everything goes right, so the result is true, but he insists on entering the echo line

  • Have you tried casting the back? if ( (bool)$result == false ){ ... }

  • It was one of the first things I did... but it didn’t work

  • And so? if( $result === false )

  • Forgive me guys, the script is correct, what happens is that in REST is not in the manual that it would return me a message even the answer being true... I hoped that it did not come answer string only true boolean type, what I do delete the question?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.