Including pages and die()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Including pages and die()

Post by nigma »

My webpage is http://www.nigmanet.net as you can probably notice I have a file called index.php that takes a GET variable called 'id'. That id represents the index of an array that has the name of the file to be included. Then here is how it goes from there:

Code: Select all

include_once('toppage.html');
include_once($arrayї$id]);
include_once('bottom.html');
Now that works fine. But what if I use die() in the page that is included second? Then bottom.html is not included. Is there an easy way around this that allows you to still include all three files?

Thanks for any help provided.
User avatar
Crashin
Forum Contributor
Posts: 223
Joined: Mon May 06, 2002 3:42 pm
Location: Colorado

Post by Crashin »

I suppose I'd just not use die. Instead, check to see if a condition is met before doing what you want to do. E.g.

Code: Select all

<?php
$var = blah, blah, blah;
if ($var = what you wanted) {
     do what you wanna do;
}
?>
I'm sure that's obvious. But, as far as I know die is like exit. Once it's called all further code is ignored, nay, not even read.
Post Reply