Re: Question about empty();
| From: | Mike Migurski | Date: | Tue, 18 Nov 2003 16:29:06 +0000 |
| Subject: | Re: Question about empty(); | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-170124@lists.php.net to get a copy of this message | ||
>This function I don't get at all, I hear all the time, "if you want to
>practice smart coding then turn register globals off, and be sure you keep
>query data out of your script that is not set or defined with something
>expected". So why would there be a function that returns true or false, $var
>is empty even if $var is not defined!
It's just a shorthand that helps avoid tests like the one below, common in
a user input validation situation:
(!isset($_POST['var']) || ($_POST['var'] == ''))
Instead, you can use:
empty($_POST['var'])
---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca http://mike.teczno.com/contact.html