# Substring writes and buffered char streams

- Thread: https://externals.io/message/11988
- Original archive: https://news-web.php.net/php.internals/11988
- Started by jtl_phpdotnet@spamex.com on 2004-08-07T13:14:35+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #11988 — jtl_phpdotnet@spamex.com — 2004-08-07T13:14:35+00:00

URL: https://externals.io/message/11988#11988

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
