如何用php referer获取youtube视频ID?

I want to track where exactly is click from youtube video. U have tried with this code. But its return only "www.youtube.com/". I want to print this "https://www.youtube.com/watch?v=_bnur3gHJ0s"

<?
$whr = $_SERVER['HTTP_REFERER'];
print_r($whr);
?>

Regex is probably your best method of choice. There's a post here that should benefit you.

PHP Regex to get youtube video ID?

Because of HTTPS, you dont (always) get a referer. You could check with print_r($_SERVER) if there is something else, but don't rely on it too much.

A better solution would be to add a referer as get parameter, eg:
- example.com/somepage?ref=youtube_description
- example.com/somepage?ref=video&video=12345