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 level e_notice issued when happens. see manual entry on why $foo[bar] wrong (unless first define() 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; } 

http://codepad.org/3kb6vcmo

produces:

string(7) "falsify" bool(false) 

the first evaluates true, hence if seeing logically true.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -