Empty member variable is not empty

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    Empty member variable is not empty

    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
    Code:
    <br><br>
    <br><br>
    <br>strlen 6 <br>
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Try var_dump. That should tell you exactly what the variable is.

    Comment

    • code green
      Recognized Expert Top Contributor
      • Mar 2007
      • 1726

      #3
      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.

      Comment

      • code green
        Recognized Expert Top Contributor
        • Mar 2007
        • 1726

        #4
        It was a html <br> tag.
        var_dump and var_export showed
        Code:
        string(4) "
        "
        Looking at the source code behind the web page revealed
        Code:
        string(4) "<br>"
        Have handled the problem.
        Thanks for the tip Atli

        Comment

        Working...