Skip to content

Instantly share code, notes, and snippets.

@titomus
Created August 10, 2017 07:19
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 titomus/ef1e6fcd4ead7b88c445f5673eae605f to your computer and use it in GitHub Desktop.
Save titomus/ef1e6fcd4ead7b88c445f5673eae605f to your computer and use it in GitHub Desktop.
Récupérer la racine du referer
<?php
function racine_referer()
{
if (!isset($_SERVER['HTTP_REFERER'])){
return false;
}else{
$parser_url = parse_url(trim($_SERVER['HTTP_REFERER']));
return trim($parser_url[host] ? $parser_url[host] : array_shift(explode('/', $parser_url[path], 2)));
}
}
//utilisation
echo racine_referer();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment