if statement with just one variable as conditionals-php -
i trying study php , came across if statement has single variable conditional this:
<?php if($a){ //do } ?>;
i know c++ , javascript, in languages, if statement ben invalid. tell me if statement means?
as rizier123 said above, conditional checking "truthy" values in variable $a. in loosely-typed language php, truthy value non-empty, non-null, or non-zero value.
see great answer similar question:
https://stackoverflow.com/a/6693908/2796449
or php docs:
http://php.net/manual/en/language.types.boolean.php
boolean logic reduces down entire statement down 1 value, either true or false. executing "echo (3==4);" show false. if variable returns truthy value, evaluated true.
these 3 comparable statements:
$a = 1;
if ( $a )
if ( 1 )
if ( true )