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

王林
王林Original
2020-08-01 13:26:093322browse

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 ] )

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'];
}

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!

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