I'm a beginner in PHP programming(or any other for that matter) and I'm facing a problem while trying to work on my first real world project. I have two parameters in my url, category and item, I want to use them in an if condition like this, like if they're both there, display something:
if ($_GET["category"] && $_GET["item"]) {
echo "Success";
}
Is this even possible? I have tested the parameter values with echo outside if/elseif statements and they work. Also, if I use a single query parameter with if statement, it works.
Thanks a lot for your time. Regards.
P.S PHP version = 5.2.6.
Cleanest way to do this:
if (isset($_GET["category"],$_GET["item"]) && !empty($_GET["category"]) && !empty($_GET["item"])) {
echo "Success";
}
your code need to be changed to
if (isset($_GET["category"]) && isset($_GET["item"])){
echo "Success"
}
checking if empty will need empty($_GET["category")
to be added