Is it possible to see if the user requests "example.com/mypage/?" or "example.com/mypage/" ?
I would like to serve different content if the query string is symbol "?" is present in the request. Please note that there is no name or value (e.g. ?name=value) , just the request symbol "?". A solution in python would be excellent but php is acceptable too.
In PHP you can check if the REQUEST_URI
ends in a ?
. There are three different cases that might be of use to you:
if('?' === substr($_SERVER['REQUEST_URI'], -1)){
// Empty query string with '?'
}else if(false === strpos($_SERVER['REQUEST_URI'], '?')){
// No ? at all
}else{
// Some query string exists (check $_GET)
}
Take the $_SERVER['REQUEST_URI']
and check if there is any question mark in it.
if(strpos($_SERVER['REQUEST_URI'], "?") >= 0) {
//Question mark found
}
checking the last character
if ('?' === substr($_SERVER['REQUEST_URI'], -1))