PHP Redirect Function
After form submission or a page redirect is triggered, it's commonplace to redirect the user to a different page or to the same page, formatted in a different way. Usually, you'd complete this by coding:
This is a completely acceptable way to code your pages, but I prefer to use a redirect function instead. Why? It's much more readable, and quite honestly, I'm tired of writing the header('Location: …') code.
function redirect($url,$permanent = false)
header('HTTP/1.1 301 Moved Permanently');
Do you have any suggestions for improvement?
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)