Reputation: 21617
I am using the below to get the referring URL but what I would like to check is whether $ref
has a variable in it.
Referring Link http://domain.com/?s=checking
Current Link http://domain.com/product/cheese
Ideally I would like to be able to use PHP to check if the variable $ref
has the GET Variable s
in it
PHP
$ref = $_SERVER['HTTP_REFERER'];
Upvotes: 0
Views: 71
Reputation: 522024
$queryParams = parse_url($ref, PHP_URL_QUERY);
if ($queryParams) {
parse_str($queryParams, $values);
if (isset($values['s'])) {
echo 'Has query param s: ', $values['s'];
}
}
Upvotes: 3