Search the Community
Showing results for tags 'false'.
-
Hi there, I have a simple question to ask: Say i have a PHP script: <?php var_dump($undeclaredVariable); /* The output is NULL */ if($a==$b) { if($c == $d) { $undeclaredVariable = TRUE; } else { $undeclaredVariable = FALSE; } } if($undeclaredVariable == TRUE) { echo 'the undeclared variable is TRUE'; } if($undeclaredVariable == FALSE) { echo 'the undeclared variable is FALSE'; } ?> Reading the PHP Type Comparison Table: $x = null; boolean if($x) = FALSE Using the code above, I see the "the undeclared variable is FALSE", which is OK since it proves the PHP documentation. But as you can see, if $a !=$b then the $undeclaredVarable will not be declared(defined). Is this an "OK" way to work this out? Or should I find a way to declare the variable whatever the case? Thanks in advance, Christos
-
In the elseif below if the $group_num is in the $dont_print I don't want add the info, what am I doing wrong $dont_print = array(0, 12); foreach ($group_array as $key => $group_num) { if (!$add_on_sql) {$add_on_sql = 'WHERE id_group = '.$group_num.'';} elseif (in_array($group_num, $dont_print, FALSE)) {$add_on_sql .= ' OR id_group = '.$group_num.'';} } Thanks