Is this valid? I want to check if 'One' is not blank AND two is either blank or undefined. Can i use the brackets that way around both of GET[two]?
if( $_GET["one"] == '' && ($_GET["two"] == '' || $_GET["two"] == 'undefined') ) {
// do X
}
Thanks
Yes, it's certainly valid. Basically, your if checks if BOTH cases (1) one == '' and (2) two == '' or two == 'undefined' exists. (2) evaluates as true if two is either '' or 'undefined'
The brackets are perfectly valid. :)
Yes, that is valid. It should do exactly what you want.
If you need to check for empty strings or NULL
values, you can also use the empty()
function:
if (empty($_GET['one']))