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);
}

관련자료

댓글 0
등록된 댓글이 없습니다.
Today's proverb
미모의 아름다움은 눈만을 즐겁게 하나 상냥한 태도는 영혼을 매료시킨다. (볼테르)