note 55969 deleted from language.expressions by googleguy

From: Date: Tue, 22 Oct 2013 14:53:44 +0000
Subject: note 55969 deleted from language.expressions by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-197206@lists.php.net to get a copy of this message
Note Submitter: stochnagara at hotmail dot com ---- 12345alex at gmx dot net 's case is actually handled by the === operator. That's what he needs. There is also another widely used function. I call it myself is_nil which is true for NULL,FALSE,array() and '', but not for 0 and "0". function is_nil ($value) { return !$value && $value !== 0 && $value !== '0'; } Another useful function is "get first argument if it is not empty or get second argument otherwise". The code is: function def ($value, $defaultValue) { return is_nil ($value) ? $defaultValue : $value; }

« previous php.notes (#197206) next »