RE: [PHP] How to make program execution go to another file?
| From: | Vail, Warren | Date: | Thu, 20 May 2004 21:28:09 +0000 |
| Subject: | RE: [PHP] How to make program execution go to another file? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-186631@lists.php.net to get a copy of this message | ||
This is a common problem for people coming from other languages where the
file structures are the same as the execution structure. A few of at least
50 answers is as follows;
Force the browser to invoke your next program;
If(1==a) {
header("Location: this.php");
exit; //stop this script
}
If(1==b) {
header("Location: that.php");
exit;
}
If(1==c) {
header("Location: other.php");
}
Another option would be to take advantage of conditional includes to bring
the code into the current script;
If(1==a) {
include("this.php");
exit;
}
If(1==b) {
include("that.php");
exit;
}
If(1==c) {
include("other.php");
}
Include will issue a warning if executed and the file does not exist.
Require is fatal if executed and the file does not exist.
You can, of course use;
if(file_exists("this.php")) include("this.php");
to suppress any warning at all.
Warren Vail
-----Original Message-----
From: michael young [mailto:mhyoung@valdosta.edu]
Sent: Thursday, May 20, 2004 2:12 PM
To: php-general@lists.php.net
Subject: [PHP] How to make program execution go to another file?
Hi,
I want program execution to go to one of several other files
based on a decision.
For Example.
if (1==a)
go to this .php file
if (1==b)
go to that .php file
if (1==c)
go to the other .php file
Thank you for your time.
Michael
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php