Home > Backend Development > PHP Problem > How to get the real url after jump in php

How to get the real url after jump in php

王林
Release: 2023-03-03 17:08:02
Original
3324 people have browsed it

php method to get the real url after the jump: You can use the get_headers() function to get it. The get_headers() function is a system-level function that returns an array containing the headers sent by the server in response to an HTTP request.

How to get the real url after jump in php

get_headers() is a system-level function in PHP that returns an array containing the headers sent by the server in response to an HTTP request. If it fails, it returns FALSE and issues an E_WARNING level error message (which can be used to determine whether the remote file exists).

(Recommended tutorial: php graphic tutorial)

Function syntax:

array get_headers ( string $url [, int $format = 0 ] )
Copy after login

Parameters:

  • url Required. Target URL

  • format Optional. If it is 1, parse the corresponding information and set the array key name.

(Learning video recommendation: php video tutorial)

Code implementation:

$headers = get_headers('将跳转的URL');
if ($headers && $headers['Location']){
	echo $headers['Location'];
}
Copy after login

The above is the detailed content of How to get the real url after jump in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template