Home > Article > Backend Development > PHP mobile phone cannot jump to domain name
php mobile phone cannot jump to the domain name
Sometimes you encounter the problem that the header Location cannot be redirected on the mobile phone , below we use js instead of header location to implement domain name jump.
header("Location:http://www.php.cn");
was changed to
header('HTTP/1.1 301 Moved Permanently'); header("Content-type:text/html;charset=utf-8"); echo "<script>"; echo "location.href='http://www.php.cn'"; echo "</script>";
header() for sending native HTTP headers.
header() must be called before any actual output, whether it is ordinary HTML tags, empty lines, or spaces in file or PHP output. This is a common mistake. When accessing functions in other files through include, require, or other functions, if there are spaces or blank lines before header() is called. The same problem exists with separate PHP/HTML files.
For more PHP related knowledge, please visit PHP Chinese website!
The above is the detailed content of PHP mobile phone cannot jump to domain name. For more information, please follow other related articles on the PHP Chinese website!