I'm learning PHP and I hoping you can explain why the author of a shopping cart tutorial has done this in a call to add a product to a cart.
if(isset($_GET['action']) && $_GET['action']=="add")
The site checks that $_GET[action]
is set and that $_GET[action]
is equal to 'add' before processing but isn't this functionally equivalent to just:
if($_GET['action']=="add")
Because if the value is 'add' it has to be set, and if it's not set it can't possibly be 'add' right? Or am I missing something?
No, thats not the same Let me explaint 1. isset check either key is set in array 2. Double equals check the simple comparison
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With