본문 바로가기
  • 행복하게 오래오래 개발자로 살아가기
Old/PHP

simplexml error handling

by yundev 2013. 3. 21.
반응형

만약 simple_load_string 또는 simpe_load_file로 에러가 발생했을 시, 핸들링하는 방법

$use_errors = libxml_use_internal_errors(true);
$xml = simplexml_load_file($url);
if (!$xml) {
  //throw new Exception("Cannot load xml source.\n");
}
libxml_clear_errors();
libxml_use_internal_errors($use_errors);

참고 사이트 : http://stackoverflow.com/questions/1307275/simplexml-error-handling-php

반응형

'Old > PHP' 카테고리의 다른 글

PHP 관계 연산자  (0) 2013.03.26
php mysql_result에 관하여  (0) 2013.03.21
phpmailer  (0) 2013.03.21
WeatherBug 날씨  (0) 2013.03.18
특정 문자열 사이에 있는 값 가져오기  (0) 2013.03.15