daniel daniel - 1 month ago 5
PHP Question

compare variable with $_SERVER['REQUEST_URI']

I have got variable

$page
. This Variable holds the value of the page on which I am.
Need to compare this expression:

if ($_SERVER['REQUEST_URI'] === '/index.php?page='.$page)


but its not working

Answer

Seems like it would be much more simple to do:

if ($_GET['page'] == $page)

This would also continue to work if you have more than just page in your query string.