I want to send my users to different pages based on user action. So I made multiple functions at the top of the page like so:
Try something like this:
<?php
$page = // use an if statement or whatever you need to figure out
//which page you need (pagea.php, etc.)
fnx($page)
function fnx($page) {
header("location: " . $page);
}
?>
or
<?php
$page = // use an if statement or whatever you need to figure out
//which page you need (pagea.php, etc.)
header("location: " . $page);
?>
function one() {
return "location: pagea.php";
}
function two() {
return "location: pageb.php";
}
function three() {
return "location: pagec.php";
}
header(one()); // for example
Maybe something like that?
Here is how i like to do when i need to send multiple headers :
$headers = array(
'Location' => 'http://www.stackoverflow.com',
'Content-Type' => ' application/pdf',
);
foreach ($headers as $headerType => $headerValue)
{
header($headerType . ': ' . $headerValue);
}
Use headers_sent() to check if you'll be able to send headers or not.