Alex Rivera | Logout

do I need to use exit after header("Location: http://localhost/...");?

Asked 2011-04-03T05:49:03.250
15

I'm creating a script to validate a form and I was asking myself a question. When I use a header (see example below), do I need to use exit right after? I mean, does using header also means that it is exiting by default therefore I don't need to use the command exit?

// cancel button clicked
if (isset($_POST['cancel'])) {
  header("Location: http://localhost/admin/tracks.php");
  exit;
}

echo '<p>$name</p>'
Edit
Report

1 Answer

-2

does using header also means that it is exiting by default

How so? What if your header is not Location: one but Content-type: or Cache-control or whatever else?

answered 2011-04-03T06:24:14.340

Your Answer