I’m trying to send a http get request in a php file to a server and receive the response.
function broadcastRequest($catCommand,$command,$prop){
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL,'http://'.$prop["ipServer"].':'.$prop["portVLM"].$prop["startURL"].$catCommand."%20".$prop["broadcastName"].'%20'.$command);
curl_setopt ($ch, CURLOPT_HEADER, 0);
$res = curl_exec ($ch);
$res = simplexml_load_file($res);
curl_close ($ch);
}
- If I echo the first
$resI can read the number 1 - the second
$reswon’t load becausesimplexml_load_file()isn’t syntax-highlighted in my Notepad++
Can someone explain to me what I’m doing wrong, or advise another way of working?
Looks like you need to set the CURLOPT_RETURNTRANSFER option. However, it’s probably easier to just do this: