I am reading PHP Cookbook, in the section about Forms there is this:
Problem: You want to make sure a value has been supplied for a form element. For example, you want to make sure a text box hasn’t been left blank.
Then the author elaborates to this:
// Making sure $_POST['flavor'] exists before checking its length
if (! (filter_has_var(INPUT_POST, 'flavor') &&
(strlen(filter_input(INPUT_POST, 'flavor')) > 0))) {
print 'You must enter your favorite ice cream flavor.';
}
I don't understand how this 'and' expression evaluates to true.
Won't !(filter_has_var(INPUT_POST,'flavor')
always be false?
Aucun commentaire:
Enregistrer un commentaire