PHP if statement comparison clarity -
i having problem php. i'm new it, driving me batty! falsify() function below works. if compare (falsify == false), echo false, why necessary? why falsify not return false without comparison?;
<?php if (falsify) { echo "true"; } else { echo "false"; } function falsify(){ return false; } ?>
if use undefined constant, php assumes mean name of constant itself, if called string (
constant
vs"constant"
). error of levele_notice
issued when happens. see manual entry on why$foo[bar]
wrong (unless firstdefine() bar
constant) ...
http://www.php.net/manual/en/language.constants.syntax.php
falsify
without ()
implicit string:
var_dump(falsify); var_dump(falsify()); function falsify() { return false; }
produces:
string(7) "falsify" bool(false)
the first evaluates true
, hence if
seeing logically true
.
Comments
Post a Comment