Possible Duplicate:
stop php processing file
Today while playing around with PHP a noticed a strange thing
I had a block of Code where it does a job.
$images = $wpdb->get_results($query);
foreach($images as $image):
$img = get_post($image->meta_value);
print_r($img);
endforeach;
And after this piece of code i tried to die; because i needed to analyse the output.
$images = $wpdb->get_results($query);
foreach($images as $image):
$img = get_post($image->meta_value);
print_r($img);
endforeach;
die;bla bla bla qit error !98123
Which means stop by this line and dont go further.
But it goes and i thought as a Scripting Language it parses Line by Line and will not go after the die;
But in fact it goes.
Does some one has any explanation for that ?
The
die()andexit()functions only stop execution of the script, which happens only after the file has been fully parsed.If you with to stop parsing itself, you must use
__halt_compiler(), see: http://php.net/manual/en/function.halt-compiler.php