By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,889 Members | 1,044 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,889 IT Pros & Developers. It's quick & easy.

Empty member variable is not empty

code green
Expert 100+
P: 1,726
strlen reports a length of 6 even though it is empty.
Also if(empty) reports true.
What is happening
[PHP]echo '<br>'.$this->message;
trim($this->message);
echo '<br>'.$this->message;
if(empty($this->message))
return;

$this->message .= '<br>strlen '.strlen($this->message).
' '.$this->message;
echo '<br>'.$this->message;[/PHP]
The web page source code is
Expand|Select|Wrap|Line Numbers
  1. <br><br>
  2. <br><br>
  3. <br>strlen 6 <br>
Oct 1 '08 #1
Share this Question
Share on Google+
3 Replies


Atli
Expert 5K+
P: 5,058
Try var_dump. That should tell you exactly what the variable is.
Oct 1 '08 #2

code green
Expert 100+
P: 1,726
OK Atli I will take a look.
This has had me baffled for a few weeks now.
It is part of an error handling class that reports script problems via email.
Nothing critical, but it means I am getting annoying empty emails.
Oct 2 '08 #3

code green
Expert 100+
P: 1,726
It was a html <br> tag.
var_dump and var_export showed
Expand|Select|Wrap|Line Numbers
  1. string(4) "
  2. "
Looking at the source code behind the web page revealed
Expand|Select|Wrap|Line Numbers
  1. string(4) "<br>"
Have handled the problem.
Thanks for the tip Atli
Oct 2 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.