and can't get this to work. I want to get variable from URL, like:
domain.com?region=STATE
if (empty($_GET)) {
echo 'American';
}
else {
$t = $_GET["region"];
if ($t == "Texas") {
echo "Texan";
} elseif ($t == "California") {
echo "Californian";
} else {
echo "American";
}
}
This does work. However in case there's wrong parameter input, like:
domain.com?asdasd=whatever
I get an error:
"Notice: Undefined index: region in test.php on line 19"
Can you tell me how can I prevent this error from appearing and basically treat it as empty variable and return "American" instead?
I tried this code, but it doesn't work:
if (empty($_GET)) {
echo 'American';
}
elseif ($_GET != "region") {
echo 'Anything Else';
}
else {
$t = $_GET["region"];
if ($t == "Texas") {
echo "Texan";
} elseif ($t == "California") {
echo "Californian";
} else {
echo "American";
}
}
Even if URL is true:
domain.com?region=Texas
is still get "Anything Else" in the output.