function redirect($url)
{
header ("location: $url");
exit;
}
Ok, well works great, except if it gets called 2 times, on the same page...then errors take over...so How do I make it so it determines wether or not the function exists?
Predifined Function-- [PHP]
Started by liveman, Nov 20 2005 08:58 AM
2 replies to this topic
#1
Posted 20 November 2005 - 08:58 AM
Hello, Well I am making a script in php and I added
#2
Posted 20 November 2005 - 12:05 PM
I believe you asked your question wrong. The last 2 words of your question could be the answer: http://php.net/manua...tion-exists.php
But since i assume you want to know whether or not the function has been called. You could try a static variable (i haven't done much work with these, but you could give it a try.
So what you'd want to use is this:
But since i assume you want to know whether or not the function has been called. You could try a static variable (i haven't done much work with these, but you could give it a try.
function redirect($url){
static $called=0;
if(empty($called){
header ("location: $url");
$called = 1;
}
}
But i doubt that's your problem. Headers, unlike php/html, tend to be case-sensitive (mostly for cross-browser compatiblity). http://php.net/manua...tion.header.phpSo what you'd want to use is this:
function redirect($url){
header ("Location: $url");
}
exit() is not needed since that should redirect you the second it's called.
Edited by rc69, 20 November 2005 - 12:13 PM.
#3
Posted 21 November 2005 - 09:42 PM
Sorry, disremind this:/
Edited by Programmerguy150, 21 November 2005 - 09:42 PM.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
