[nycphp-talk] Returning from Includes
Matt Juszczak
matt at atopia.net
Sat Oct 2 02:34:01 EDT 2004
Hey all,
Just had a quick question. I've got a system that currently runs that has a
basic module file (module.main) which includes a couple files...
header.html, footer.html, and the current module file .... go.none is included
if $go is NULL, action.none is included if $action is NULL .... if action is
UpdateUserInfo and go is ManageUser then action.UpdateUserInfo and
go.ManageUser is included ... and so on and so forth.
go.* is the text displayed to the screen and UpdateUserInfo is the include of
the action that does updating, deleting, etc....
It all works great, except for when someone modifies the URL ... for instance,
changing go from NULL to go equals "ManageUser" .... go.ManageUser requires a
userID, which is hard to check for in go.ManageUser because it pushes all the
code in ....
for instance:
File go.ManageUser
if (!empty($UserID))
{
echo "missing";
}
else
{
// 100 lines of code here ... indented... :-(
}
I could do something else like
if (!empty($UserID))
$errors = "Missing file";
if (empty($errors))
{
// 100 lines of code here
}
but that still does the indent ... so what i want to do is this:
if (empty($errors))
{
return; // return from the include
}
//rest of code here
I can't do an exit; because then it won't go back to the main "module" file and
print footer.html, so the page will look messed up. Will that single return
work though? What if I wanted to do multiple layers? I've tried this and I
can't seem to get it working like i want it to. Is there a better way?
Thanks :)
-Matt
More information about the talk
mailing list