PHP method to obtain redirect URL: 1. Use get_headers function to obtain, syntax "get_headers($url, 1)"; 2. Use fsockopen() function to obtain; 3. Use curl_init(), curl_setopt() and other functions to obtain.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
1. Use the get_headers function
The get_headers function that comes with php can get all the headers sent by the server in response to an HTTP request. We can try to use this function to implement it.
1 2 3 4 5 6 7 8 9 10 11 12 |
|
2. Use the fsockopen() built-in function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
3. Use the cURL function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
Recommended learning: " PHP video tutorial》
The above is the detailed content of What are the several ways to get the redirect URL in PHP. For more information, please follow other related articles on the PHP Chinese website!