Ok, so I have PHP set upp to ato_prepend and auto_append files to every script
I run. So if I someone surfs to /index.php, these scripts run:
init.php -> set up DB connections and stuff. Buffers output
index.php -> The current page with it's layout, output is buffered.
postprocess.php -> Fetches buffer, applies layout to page.
Now, sometimes I want to break the execution of index.php (or whatever page
that is in the middle). For example, when someone submits a form with
insufficient data, I want to quit executing code and just put up an alert. But
if I use "die;", then PHP will stop executing all code, it won't just stop
executing the code in index.php.
Is there a way to tell PHP to stop executing code in the current script, but
continue with the next? I would guess that the same could apply to include()'d
files, where I want the execution of the included file to stop, but the page
that included the file shouldn't stop executing. I.e.:
<?
print "Hello ";
include("world. php");
print "!";
?>
And "world.php" would in this case just output "World", but by using some
method, I could just break the execution of world.php from within world.php
(without using large IF blocks) and the result would then be "Hello !" from the
page, and not "Hello " which happens if I use "die;" in world.php.
Any suggestions?
--
Sandman[.net]
I run. So if I someone surfs to /index.php, these scripts run:
init.php -> set up DB connections and stuff. Buffers output
index.php -> The current page with it's layout, output is buffered.
postprocess.php -> Fetches buffer, applies layout to page.
Now, sometimes I want to break the execution of index.php (or whatever page
that is in the middle). For example, when someone submits a form with
insufficient data, I want to quit executing code and just put up an alert. But
if I use "die;", then PHP will stop executing all code, it won't just stop
executing the code in index.php.
Is there a way to tell PHP to stop executing code in the current script, but
continue with the next? I would guess that the same could apply to include()'d
files, where I want the execution of the included file to stop, but the page
that included the file shouldn't stop executing. I.e.:
<?
print "Hello ";
include("world. php");
print "!";
?>
And "world.php" would in this case just output "World", but by using some
method, I could just break the execution of world.php from within world.php
(without using large IF blocks) and the result would then be "Hello !" from the
page, and not "Hello " which happens if I use "die;" in world.php.
Any suggestions?
--
Sandman[.net]
Comment