Re: passing control to a separate script
| From: | Stuart Dallas | Date: | Mon, 02 May 2011 08:55:18 +0000 |
| Subject: | Re: passing control to a separate script | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-312618@lists.php.net to get a copy of this message | ||
On Monday, 2 May 2011 at 05:21, Jim Giner wrote:
Script 1 calls script 2. Script 2 has several paths in it which is how the
> user gets to interact with it. Once the final path has been taken (data
> gets written) I don't want to use script 2 any longer - I want script 1 to
> begin, by a call from the "executing" script 2 that will initiate script 1
> and then script 2 goes away since script 1 will have control. It's kind of
> like passing a baton in a relay race.
You want script 1 to begin again? In that case simply include script1 from script2 then call exit
immediately afterwards. The only way to make use of another script without it returning back to the
current script once it's done is if that other script calls exit or die to end execution.
When you say script 1 "calls" script 2, what do you actually mean? Is it included, are you
calling a function in script 2, or is the user clicking on a link / submitting a form that runs
script 2?
To get "script 1 to begin" from script 2 based on a certain path...
script2.php
---
if ($path1)
{
// do stuff here
include('script1.php');
exit;
}
// otherwise do other stuff here
---
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/