Skip to content
Snippets Groups Projects
Commit 67234204 authored by Andreas Gohr's avatar Andreas Gohr
Browse files

removed isset() from blank() function

As discussed in #1471, an uninitialized variable will always be
implicitly created when passed to the blank() function. Calling isset()
is thus a no-op. A warning about this behavior has been added to the
function comment.
parent 3258ecf1
No related branches found
No related tags found
No related merge requests found
......@@ -35,12 +35,19 @@ function hsc($string) {
*
* This is similar to empty() but will return false for "0".
*
* Please note: when you pass uninitialized variables, they will implicitly be created
* with a NULL value without warning.
*
* To avoid this it's recommended to guard the call with isset like this:
*
* (isset($foo) && !blank($foo))
* (!isset($foo) || blank($foo))
*
* @param $in
* @param bool $trim Consider a string of whitespace to be blank
* @return bool
*/
function blank(&$in, $trim = false) {
if(!isset($in)) return true;
if(is_null($in)) return true;
if(is_array($in)) return empty($in);
if($in === "\0") return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment