It's a fictitious example. And I want to understand "What really happens when using EXIT in this code":
function my_template_redirect() {
$page = get_query_var('pagename'); //get some value
if ( $page == 'products' ): //compare with something
//show products
EXIT;
elseif ( $page == 'product' ): //compare "else"
//show product
EXIT;
endif;
}
add_filter( 'template_redirect', 'my_template_redirect' );
Ok. Step by step execute (my own logical version)
|-code executing
|-filter callback my_template_redirect()
|-if start (or else)
|-exit
|-start execute new template
What happen after EXIT call? Control structure IF:ENDIF automatically closes? Or still opened in new code? Is this bad way to organize code?
Thanks in advance!
PS I'm using WP example for better understanding my bad English :)
exitterminates the script. Nothing can happen "after" callingexitbecause the script is dead. e.g. RTFM: php.net/exitreturnin these instances.