i have snippet of code behaviour not understand. true value giving different result when passed empty()
in different copies of variable.
var_dump($this->controller->type['company']['is_active']); // bool(true)
property $controller
object $type
property multi array. value of is_active
bool(true)
what should result of empty()
?
var_dump(!empty($this->controller->type['company']['is_active'])); //false
ok, let's create copy
$temp = $this->controller->type['company']['is_active']; var_dump(!empty($temp)); //true
hmmm different result?
var_dump($this->controller->type['company']['is_active'] === $temp);//true
what casting?
var_dump(!empty((int)$this->controller->type['company']['is_active'])); //true
could explain behaviour please?
please refere php manual, http://php.net/manual/en/function.empty.php
returns false if var exists , has non-empty, non-zero value. otherwise returns true.
note empty works pass variable not pass value.
the following things considered empty:
""
(an empty string)0
(0 integer)0.0
(0 float)"0"
(0 string)null
false
array()
(an empty array)$var;
(a variable declared, without value)
Comments
Post a Comment