고찰 3. break, return, exit, die 탈출문 정리 -php

 

 

break = 루프 탈출

- for, foreach, while 등 여러 번 반복되는 루프의 경우에 해당됨

- 루프 이후에 등장하는 코드를 계속 실행함

- if문은 반복문이 아니라 조건 충족 시 1번만 실행되는 코드이므로 해당 없음

 

return = 함수 탈출 또는 인클루드 탈출

- 함수 안에서 쓰면 함수 실행을 종료하고, 그 함수를 호출했던 지점으로 돌아가서 계속 실행함

- 함수 밖에서 쓰면 현재 파일을 인클루드했던 파일로 돌아가서 계속 실행함

- 함수 밖인데 인클루드한 것도 없으면 그냥 종료됨, exit과 동일한 효과가 됨

 

exit, die = 무조건 종료

- 말 그대로 프로그램이 죽어버림

Posted by star story :

Snippet :: Code View :: "+location.href+'
'+b+"

");top.consoleRef.document.close()}$(".snippet-container").each(function(b){$(this).find("a.snippet-text").click(function(){var d=$(this).parents(".snippet-wrap").find(".snippet-formatted");var c=$(this).parents(".snippet-wrap").find(".snippet-textonly");d.toggle();c.toggle();if(c.is(":visible")){$(this).html("html")}else{$(this).html("text")}return false});$(this).find("a.snippet-window").click(function(){var c=$(this).parents(".snippet-wrap").find(".snippet-textonly").html();a(c);$(this).blur();return false})});$(".snippet-toggle").each(function(b){$(this).click(function(){$(this).parents(".snippet-container").find(".snippet-wrap").toggle()})})});