php - Null value showing, despite if statement to get rid of it -


i have following code (see below) ... if statement should checking see if $re_broker has value (and not null) ... however, if statement displaying code "null" value.

i've tried if statement each of following...

// isset($re_broker) // $re_broker!='' // !empty($re_broker) // $re_broker!='null' // $re_broker!=null 

... none have worked. reason why happening? , how fix it? i'm sure simple, can't figure out.

<?php if(!empty($re_broker)) { ?>      <div class="auth-box auth-outline broker">           <div class="auth-txt"><?php echo $re_broker; ?></div>      </div>      <div class="clear"></div><?php } ?> 

if seeing word "null" printed on screen, means $re_broker string containing "null", , not null. null variable should not evaluate string on echo. investigate , perhaps post code sets variable.

in php, non-empty string evaluates true, regardless of characters holds. "false" == true, , "null" == true. can little tricky. , why code block running despite being "null"

also, should use isset() or is_null() test null. functions empty() not testing null.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -