In PHP, when you have something in the URL like “var=true” in the URL, does the ‘true’ and ‘false’ in the URL get translated to boolean variables, or do they equal the text ‘true’ or ‘false’? For instance, would, with the url having “var=false” in it:
if ($_GET['var'] == false) { ... }
work? Or would the variable always be true since it has text in it?
They are passed as strings, so are always truthy unless they are one of these, which evaluate to false instead:
'''0'To make my life easier I just pass boolean GET variables as
1or0and validate them to be either one of those values, or decide on a default value appropriately: