Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is break; required after die() php

I've been thinking to much...

In the area of switch case is break; required after die()

Example:

switch($i){

     case 0:
          die('Case without break;');

     case 1:
          die('Case with break;');
          break;

}
like image 708
Evan Stoddard Avatar asked Aug 09 '13 19:08

Evan Stoddard


1 Answers

die() is just an alias for exit(), where exit() will terminate the program flow immediately. (Shutdown functions and object destructors will still get executed after exit())

And no, it is not a syntax error to omit the break, on the contrary there are many useful cases for omitting the break. Check the manual page of the switch statement for examples.

like image 182
hek2mgl Avatar answered Sep 24 '22 22:09

hek2mgl