Substring writes and buffered char streams
| From: | jtl_phpdotnet at spamex dot com | Date: | Sat, 07 Aug 2004 13:14:35 +0000 |
| Subject: | Substring writes and buffered char streams | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-11988@lists.php.net to get a copy of this message | ||
Hello PHP gurus,
The php-general list does not believe that PHP allows me to do either of the following:
(1) Writing an arbitrary substring of a string directly to a stream without first creating a string
object for the substring. I.E. There is no print($string, $start, $length) or fwrite($resource,
$string, $length, $start).
(2) Creating multiple independent buffered characters streams. It appears that stdout is the only
instance available.
I need to be able to do the first to prevent a costly proliferation of string objects when parsing
an input string and producing a new output string from it's substrings. My experience writing
Java parsers for business portals clearly demonstrates that object creation, and particularly string
creation, is a limiting factor to throughput. Fixing this problem in PHP seems easy: we just need
to add an optional start-offset parameter to fwrite().
I don't think I absolutely need the second feature, as I'm emulating multiple buffered
character streams by saving and restoring the contents of stdout (via the output buffer) when
switching between instances. I just have to keep the application smart about switching so that I
can minimize the switch costs. However, it's possible that this could become an issue.
I can't create or use a PHP module since my customers generally only have FTP access to their
web sites -- not even telnet, much less the ability to customize their PHP configuration.
So, is it truly impossible to do these things? If so, when could I hope to see these features -- or
at least feature (1) -- ship with core PHP?
Thank you for your help!
~joe