note 25975 added to function.empty

From: Date: Sun, 13 Oct 2002 23:24:25 +0000
Subject: note 25975 added to function.empty
Groups: php.notes 
Request: Send a blank email to php-notes+get-38037@lists.php.net to get a copy of this message
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. -- http://www.php.net/manual/en/function.empty.php http://master.php.net/manage/user-notes.php?action=edit+25975 http://master.php.net/manage/user-notes.php?action=delete+25975 http://master.php.net/manage/user-notes.php?action=reject+25975

« previous php.notes (#38037) next »