logic - Does PHP if statement assume you are checking for 'true' if left blank? -


i once thought read somewhere if have php script this:

public function test($something){     if($something == "true"){         return true;     }else{         return false;     } }  if(test("true")){     echo "returned true"; } 

then should work fine if statement assumes checking if true when left blank? true, , if 'good programming' leave blank or should finish off statement sake of not cutting corners?

if($variable) 

is pretty saying

if($variable != null && $variable != false && $variable != 0) 

so long variable set , not equal 0 or false evaluated true

"and if 'good programming' leave blank or should finish off statement sake of not cutting corners?"

if trying evaluate equal true, cutting corners, pretty common use if($variable) confirm $variable defined value


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -