How to jump to a new window in php

coldplay.xixi
Release: 2023-03-04 08:38:02
Original
6506 people have browsed it

How to jump to a new window in php: 1. Use the [header()] function to output the HTTP protocol header to the browser; 2. Use the meta tag to provide document meta information tags, which can realize page jumps. ;3. Use javascript to automatically jump to the new address.

How to jump to a new window in php

php method to jump to a new window:

The first way: header()

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 ]] )
Copy after login

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 parameterhttp_response_codeForce 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:

 
Copy after login

Note:

  • There cannot be any output before the header is executed

  • ##location and : There can be no spaces between

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

Second One way: meta tag

Meta tag is a tag in HTML responsible for providing document meta-information. Using this tag in a PHP program can also achieve page jumps. If http-equiv is defined as refresh, when the page is opened, it will jump to the corresponding page within a certain period of time based on the value specified by content.

< meta http-equiv="refresh" content="1;url=http:// www.baidu.com">
Copy after login

The third way: javascript

By using windows.location.href='url'; the page automatically jumps to the new address

< ?php $url = "http://www.baidu.com"; echo "< script language='javascript' type='text/javascript'>"; echo "window.location.href='$url'"; echo "< /script>"; ?>
Copy after login
Related learning recommendations:

php programming(video)

The above is the detailed content of How to jump to a new window in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!