| 123456789101112131415161718192021222324252627282930 |
- <?php
- /**
- * Created by PhpStorm.
- * User: chendeben
- * Date: 2019-01-11
- * Time: 17:41
- */
- echo getRealUrl($_GET['url']);
- function getRealUrl($url)
- {
- //得到百度跳转的真正地址
- $header = get_headers($url, 1);
- if (strpos($header[0], '301') || strpos($header[0], '302')) {
- if (is_array($header['Location'])) {
- //return $header['Location'][count($header['Location'])-1];
- $_url = $header['Location'][0];
- } else {
- $_url = $header['Location'];
- }
- } else {
- $_url = $url;
- }
- $url = parse_url($_url);
- return $url['host'];
- }
|