Landon Call Landon Call - 1 month ago 8
PHP Question

Find if url query "id" is equal to tab-1

This is what I have for my code.

$query = $_GET['id'];

if(isset($query) == tab-1) {
echo $query;
}else{
echo "nope";
}


The above code is checking if my url has /?id but it isn't checking if the ?id is equal to tab-1.

It returns true even if my url is /?id=tab-2 and $query is equal to tab-2.

Answer
if(isset($_GET['id'])) {
    $query = $_GET['id'];

    if($query == "tab-1") {
       echo $query;
    } else {
       echo "nope";
    }
}