Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurozumi/1a5191578a3265ec6f1b to your computer and use it in GitHub Desktop.
Save kurozumi/1a5191578a3265ec6f1b to your computer and use it in GitHub Desktop.
短縮URLなどのリダイレクト先のURLを取得する関数
<?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