What potential issues or differences may arise when trying to extract keywords from a Google image search HTTP_REFERER URL?

When trying to extract keywords from a Google image search HTTP_REFERER URL, one potential issue that may arise is that the URL may not contain the keywords directly, making it difficult to extract them. To solve this issue, you can use regular expressions to search for patterns in the URL that may indicate the presence of keywords.

$referer_url = $_SERVER['HTTP_REFERER'];
$keywords = '';

if (preg_match('/q=([^&]+)/', $referer_url, $matches)) {
    $keywords = urldecode($matches[1]);
}

echo $keywords;