php constants / header location

Soldato
Joined
6 Feb 2004
Posts
20,851
Location
England
bah. i've been dabbling with php for a few months on and off and have only just discovered constants. :o very useful. :p

i was expecting this to work but it doesn't.... :o

Code:
define(PAGE, 'blah.php');
....
header("Location: PAGE");

i've also tried

Code:
header("Location: '.PAGE.'");

but that didn't work either. as you can tell i have no idea what i'm doing. is there anyway i can get this to work? :)
 
I believe the "header" has to be the first thing that gets outputted to the browser. Maybe define(PAGE, "blah.php"); is sending something to the browser before "header"
 
nope, i don't get that sort of error. it literally passes the text PAGE to the browser instead of the value of PAGE

Code:
$string = 'blah.php';
header("Location: $string");

works just fine. but the reason i want to use define is because i can use it in functions without having to worry about declaring global variables or anything like that.
 
Back
Top Bottom