Skip to content
Advertisement

PHP – comparing 2 identical strings returns false

I have read some posts about this problem. Tried to use trim but it does not help.

Php script sends a curl request to another server which returns ok if the request were successful.

$request = curl_send_function($uid, "suspend");
if ($request != 'ok') {
echo $request;
exit;
}

The script shows ok and stops to excecute – exits. Why ok is not ok for the script?

var_dump($request); shows the following:

okstring(0) ""

Advertisement

Answer

Your “ok” isn’t saved in $request but printed by your curl_send_function. You need to set the cURL option CURLOPT_RETURNTRANSFER.

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement