title: PHP Header location vs JavaScript Redirect
body: <p>I am currently developing a website for my bachelor's thesis, and from my previous experience, bad use of <code>header('Location: http://www.example.com/');</code> can end up pretty messy at times.</p>
  
  <p>My question is: When or how is it good to use <code>header('Location: http://www.example.com/');</code> vs. using <code>window.location.replace("http://stackoverflow.com");</code>?</p>
  
  <p>An example: let's say we have a registration script, and after it's done, it will redirect the user towards <code>index.php</code>. Which of those is better to use, and how?</p>