aidemingsi / pb4php

Automatically exported from code.google.com/p/pb4php
0 stars 0 forks source link

The get_message_from() method may return FALSE value for empty string #8

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Class file: /message/reader/pb_input_reader.php
Class method: get_message_from()

public function get_message_from($from)
{
    return substr($this->string, $from, $this->pointer - $from);
}

The get_message_from() may return the "FALSE" value if the value of $from 
is greater than or equal to the length of "$this->string".

It is suggested that returing empty string instead of returning "FALSE" 
value. See the following example:

public function get_message_from($from)
{
    $str = substr($this->string, $from, $this->pointer - $from);
    if ($str === FALSE)
    { // empty string
        $str = '';
    }

    return $str;
}

Original issue reported on code.google.com by che...@gmail.com on 7 Jul 2009 at 11:59