Home  >  Article  >  Backend Development  >  How to prevent php page from jumping

How to prevent php page from jumping

藏色散人
藏色散人Original
2019-11-01 09:12:333766browse

How to prevent php page from jumping

Methods to prevent php page jumps

1. Header function

The main function of the header() function is to convert the HTTP protocol header (header) Output to browser.

Parameters

void header (string string [,bool replace [,int http_response_code]])

The optional parameter replace indicates whether to replace the previous similar header or add one Headers of the same type, default to replacement.

The second optional parameter http_response_code forces the HTTP corresponding code to the specified value. The Location type header in the header function is a special header call, often used to implement page jumps.

Note

1. There cannot be a space between location and ":", otherwise it will not jump.

2. There cannot be any output before using the header.

2. JavaScript

can be placed anywhere

< ?php
$url = " 
 echo "< script language=&#39;javascript&#39; type=&#39;text/javascript&#39;>"; 
 echo "window.location.href=&#39;$url&#39;";
  echo "< /script>"; ?>

For more PHP related knowledge, please visit PHP Chinese website!

The above is the detailed content of How to prevent php page from jumping. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn