note 84093 deleted from function.fread by thiago

From: Date: Mon, 27 Oct 2008 13:05:16 +0000
Subject: note 84093 deleted from function.fread by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-145816@lists.php.net to get a copy of this message
Note Submitter: ehy_key1 at hotmail dot de ---- This is a rudimentary dummy how to read all data from a stream because i got some problems with stream_get_contents() i decide to write this... class read_stream { public $fp; private $str; private $limit = 8192; public function read_data() { $this->str = ""; $len = unpack("N",fread($this->fp, 4)); return $this->rekursiv_($len[1]); } private function rekursiv_($laenge) { if ($laenge >= $this->limit) { $this->str .= fread($this->fp, $this->limit); $this->rekursiv_($laenge % $this->limit); } else { $this->str .= fread($this->fp, $laenge); } return ($this->str); } }

« previous php.notes (#145816) next »