PHP & Others

allow_url_fopen = Off 일때 simplexml_load_file 사용

페이지 정보

본문

curl 사용가능한 설정이어야 함

if(ini_get('allow_url_fopen')) {
  $xml = simpleXML_load_file($url);
}else{
  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_HEADER, false);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  $xml_raw = curl_exec($ch);
  $xml = simplexml_load_string($xml_raw);
}

관련자료

등록된 댓글이 없습니다.
Today's proverb
모든 대답을 다 아는 것보다는 거기에 또 다른 질문을 가지는 것이 더 낫다. (제임스 터버)