original_string: public function substring($start = 0, $length = null, $char = false)
      {
          if ($start !== 0) {
              $this->seek($start, true, $char);
          }
  
          $out = '';
          $to_end = is_null($length);
  
          /* If length is greater than remaining stream, use more efficient
           * algorithm below. Also, if doing a negative length, deal with that
           * below also. */
          if ($char &&
              $this->_utf8_char &&
              !$to_end &&
              ($length >= 0) &&
              ($length < ($this->length() - $this->pos()))) {
              while ($length-- && (($char = $this->getChar()) !== false)) {
                  $out .= $char;
              }
              return $out;
          }
  
          if (!$to_end && ($length < 0)) {
              $pos = $this->pos();
              $this->end();
              $this->seek($length, true, $char);
              $length = $this->pos() - $pos;
              $this->seek($pos, false);
              if ($length < 0) {
                  return '';
              }
          }
  
          while (!feof($this->stream) && ($to_end || $length)) {
              $read = fread($this->stream, $to_end ? 16384 : $length);
              $out .= $read;
              if (!$to_end) {
                  $length -= strlen($read);
              }
          }
  
          return $out;
      }
code: public function substring($start = 0, $length = null, $char = false)
      {
          if ($start !== 0) {
              $this->seek($start, true, $char);
          }
  
          $out = '';
          $to_end = is_null($length);
  
          /* If length is greater than remaining stream, use more efficient
           * algorithm below. Also, if doing a negative length, deal with that
           * below also. */
          if ($char &&
              $this->_utf8_char &&
              !$to_end &&
              ($length >= 0) &&
              ($length < ($this->length() - $this->pos()))) {
              while ($length-- && (($char = $this->getChar()) !== false)) {
                  $out .= $char;
              }
              return $out;
          }
  
          if (!$to_end && ($length < 0)) {
              $pos = $this->pos();
              $this->end();
              $this->seek($length, true, $char);
              $length = $this->pos() - $pos;
              $this->seek($pos, false);
              if ($length < 0) {
                  return '';
              }
          }
  
          while (!feof($this->stream) && ($to_end || $length)) {
              $read = fread($this->stream, $to_end ? 16384 : $length);
              $out .= $read;
              if (!$to_end) {
                  $length -= strlen($read);
              }
          }
  
          return $out;
      }
code_tokens: public function substring ( $ start = 0 , $ length = null , $ char = false ) { if ( $ start !== 0 ) { $ this -> seek ( $ start , true , $ char ) ; } $ out = '' ; $ to_end = is_null ( $ length ) ; /* If length is greater than remaining stream, use more efficient
           * algorithm below. Also, if doing a negative length, deal with that
           * below also. */ if ( $ char && $ this -> _utf8_char && ! $ to_end && ( $ length >= 0 ) && ( $ length < ( $ this -> length ( ) - $ this -> pos ( ) ) ) ) { while ( $ length -- && ( ( $ char = $ this -> getChar ( ) ) !== false ) ) { $ out .= $ char ; } return $ out ; } if ( ! $ to_end && ( $ length < 0 ) ) { $ pos = $ this -> pos ( ) ; $ this -> end ( ) ; $ this -> seek ( $ length , true , $ char ) ; $ length = $ this -> pos ( ) - $ pos ; $ this -> seek ( $ pos , false ) ; if ( $ length < 0 ) { return '' ; } } while ( ! feof ( $ this -> stream ) && ( $ to_end || $ length ) ) { $ read = fread ( $ this -> stream , $ to_end ? 16384 : $ length ) ; $ out .= $ read ; if ( ! $ to_end ) { $ length -= strlen ( $ read ) ; } } return $ out ; }
docstring: Return part of the stream as a string.
  
  @since 1.4.0
  
  @param integer $start   Start, as an offset from the current postion.
  @param integer $length  Length of string to return. If null, returns
  rest of the stream. If negative, this many
  characters will be omitted from the end of the
  stream.
  @param boolean $char    If true, $start/$length is the length in
  characters. If false, $start/$length is the
  length in bytes.
  
  @return string  The substring.
docstring_tokens: Return part of the stream as a string .