Exiting in a include page.

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
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Exiting in a include page.

Post by JellyFish »

page 1:

Code: Select all

<?php
exit; //replace with a function or that would just stop this page 1 from running.
?>
page 2:

Code: Select all

<?php
include("page1.php");

echo "This should display";
?>
How do I only exit an include script and not effect the echo statement in page 2?
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Post by Stryks »

Can you give an example of what you are trying to achieve?

Are you trying to find out how to stop page 1 being called unless page 2 requests it, or how to stop page 1 from exiting when included in page 2?

If its the latter ... ummm ... dont put exit in there?

Clarification of what you are trying to achieve might yield better feedback. 8)
User avatar
maliskoleather
Forum Contributor
Posts: 155
Joined: Tue May 15, 2007 2:19 am
Contact:

Post by maliskoleather »

i think i understand what youre asking.

use return instead of exit.

exit stops php all together. return stops the current script, and if used in a function or include, sends you back to the parent item.
Post Reply