". The main function of the function header is to output the HTTP protocol header to Browser, used to implement url jump."/> ". The main function of the function header is to output the HTTP protocol header to Browser, used to implement url jump.">

Home  >  Article  >  Backend Development  >  What is the php code that automatically jumps to the url?

What is the php code that automatically jumps to the url?

藏色散人
藏色散人Original
2020-05-09 11:32:012463browse

What is the php code that automatically jumps to the url?

What is the php code to automatically jump to the url?

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

Syntax:

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

The optional parameter replace specifies whether to replace the previous similar header or add a header of the same type. The default is to replace.

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.

Example:

<html>
<?php
/* This will give an error. Note the output
 * above, which is before the header() call */
header(&#39;Location: http://www.example.com/&#39;);
exit;
?>

Note:

There cannot be any output before the header is executed

There cannot be a space between location and:

The PHP code after the header will still be executed, so you need to pay attention to using exit;

Recommended: "php tutorial"

The above is the detailed content of What is the php code that automatically jumps to the url?. 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
Previous article:How to change txt to phpNext article:How to change txt to php