What is the equivalent function of Javascript window.location.href in PHP?

Asked

Viewed 1,608 times

4

I intend to redirect the visitor to another page so I wanted the equivalent of window.location.href in

1 answer

6


Use the function header.

header("Location: http://www.linkDoSite.com/");
exit();

According to the function documentation, it must be executed before any output is sent. This includes any HTML, plain text, blank lines, spaces or outputs from PHP itself.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.