quasiman Posted September 1, 2011 Share Posted September 1, 2011 Hi all, I'm using curl to post some data, and the response is (assuming no errors) either <boolean>true</boolean> or <boolean>false</boolean>. So if I use simplexml_load_string, the result is returned as an object. I'm trying to make this a boolean so I can handle the response, but it doesn't seem to be working....checking for false didn't stop anything from happening. Here's the problem code: $result = curl_exec($ch); $xml = settype(simplexml_load_string($result),"boolean"); if (curl_errno($ch) || $xml === false) { throw new Exception(curl_error($ch)); } Link to comment https://forums.phpfreaks.com/topic/246224-curl-xml-response-object-settype/ Share on other sites More sharing options...
onelinecoder Posted September 1, 2011 Share Posted September 1, 2011 You need to first get the index of the object: $result = curl_exec($ch); $xml = simplexml_load_string($result); $xml = settype($xml->{'0'},"boolean"); if (curl_errno($ch) || $xml === false) { throw new Exception(curl_error($ch)); } Link to comment https://forums.phpfreaks.com/topic/246224-curl-xml-response-object-settype/#findComment-1264538 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.