본문 바로가기

프로그래밍

PHP try - catch 문

반응형

메뉴얼

http://php.net/manual/en/language.exceptions.php

 

예제1)

if ($step>0) throw new Exception();

 

 

예제2)

function inverse($x) {

    if (!$x) {

        throw new Exception('Division by zero.');

    }

    return 1/$x;

}

 

예제3)

try { 

	print "this is our try block\n";

	throw new Exception();

} catch (Exception $e) {

	print "something went wrong\n";

} finally {

	print "This part is always executed\n";

}

 

getMessage() getCode()등 설명

https://www.guru99.com/error-handling-and-exceptions.html

 

PHP5.5: Try/Catch/Finally

https://adayinthelifeof.nl/2013/02/12/php5-5-trycatchfinally/

 

PHP에서 try-catch 구문을 통한 예외처리와 확장방법

http://dev.epiloum.net/1140

반응형