Now there are a lot of short Web site applications, click to jump to shorten the previous web site, then today let's take a look, PHP how to get short Web site jump to the previous web site, in fact, is also very simple, is to use php g
Now there are a lot of short Web site applications, click to jump to shorten the previous web site, then today let's take a look, PHP how to get short Web site jump to the previous web site, in fact, is also very simple, it is to use the get_headers function of php to obtain Response Headers, and then analyze it slowly.
The code is as follows:
- $ Header = get_headers ($ url, 1 );
- If (strpos ($ header [0], '000000') | strpos ($ header [0], '000000 ′)){
- If (is_array ($ header ['location']) {
- Return $ header ['location'] [count ($ header ['location'])-1];
- } Else {
- Return $ header ['location'];
- }
- } Else {
- Return $ url;
- }
Example 2: The code is as follows:
-