From the point of view of your webserver the whole page is a script, no matter the code is only one line at the top or in the middle, so if you tell it to exit, it's going to exit no matter what. Why you are using exit inside your scripts? the only case I use them is just after a header(Location ... or to do a hard error stop.