Last active
August 29, 2015 14:25
-
-
Save kurozumi/1a5191578a3265ec6f1b to your computer and use it in GitHub Desktop.
短縮URLなどのリダイレクト先のURLを取得する関数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_location($url) | |
{ | |
$headers = get_headers($url, 1); | |
if(isset($headers['Location'])){ | |
if(is_array($headers['Location'])){ | |
return array_pop($headers['Location']); | |
}else{ | |
return $headers['Location']; | |
} | |
}else{ | |
return $url; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment