note 25975 deleted from function.empty by sniper
| From: | sniper@php.net | Date: | Sat, 23 Aug 2003 00:19:43 +0000 |
| Subject: | note 25975 deleted from function.empty by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-54910@lists.php.net to get a copy of this message | ||
Note Submitter: chris @ chaska dot com
----
I've not yet found a useful purpose for the empty() function in three and half years of
programming with PHP. I'm sure there is one, but most of the time I want to know if any useful
information is in a string variable. Here's how I check for that:
function is_blank( $var ) {
if ( ! isset( $var ) ) return TRUE;
if ( strlen( trim ($var) ) == 0) return TRUE;
return FALSE;
}
Thus, if the string is *empty* of useful information (whitespace is defined as uninteresting) or for
some reason not even set, is_blank() returns TRUE. In all other cases, it returns FALSE.