Re: I need ob_write($string, $start, $length)

From: Date: Tue, 03 Aug 2004 22:59:51 +0000
Subject: Re: I need ob_write($string, $start, $length)
Groups: php.general 
Request: Send a blank email to php-general+get-192632@lists.php.net to get a copy of this message
Hi Curt, You could use a function of the name and signature you gave, but if you implement it in PHP, you're still creating the substring objects that I don't want created. Notice your call to substr(). Object creation is expensive. If the function were implemented natively, the language need only copy bytes directly from a portion of the source string over to the output buffer. Thanks for taking a stab! ~joe On 8/3/2004 Curt Zirzow wrote: >I'm not entirely clear at what your trying to do but perhaps you >want something like this: > >function print_substr_direct($string, $start, $len) { > static $fp = null; > > if ($fp === null ) { > // Open a connection directly to the output > $fp = fopen('php://stdout', 'r'); > } > if ($fp) { > fputs($fp, substr($string, $start, $len)); > } >}

« previous php.general (#192632) next »