d-_-b
d-_-b

Reputation: 23171

PHP if $_SERVER('REQUEST_URI') is empty, or only contains $_GET

How can I check if the $_SERVER['REQUEST_URI'] is empty (i.e. user visited domain.com/), but leave an exception for if there is a $_GET in the URL (domain.com/?a=1)

Upvotes: 0

Views: 3630

Answers (1)

Baba
Baba

Reputation: 95101

You can use parse_url to achieve this

if(parse_url($_SERVER['REQUEST_URI'],PHP_URL_QUERY) !== null)
{
    // It Contains get
    var_dump($_SERVER['REQUEST_URI']);
}

Upvotes: 2

Related Questions