[Proposal] Stream_Var
| From: | Stephan Schmidt | Date: | Fri, 15 Aug 2003 20:56:39 +0000 |
| Subject: | [Proposal] Stream_Var | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-19839@lists.php.net to get a copy of this message | ||
Hi PEAR-Devs,
I'd like to propose a new package called Stream_Var. This package allows
stream based access to variables using the stream wrappers that have
been introduced in PHP4.3.2
That means you can do things like:
$fp = fopen('var://GLOBALS/anyGlobalVar', 'r');
and then use fread, fwrite, fseek, etc. on this filepointer to read from
and modify the variable. It supports GLOBALS, GET, POST, etc.
If 'anyGlobalVar' is an array, it behaves like a directory, that means
you could do the following:
$fp = fopen('var://GLOBALS/anyGlobalVar/anyKey', 'r');
of course with an unlimited depth :-)
As arrays are directories, also the following is possible:
$dir = opendir('var://GET');
while($entry = readdir($dir)) {
echo "$entry<br />";
}
I still need to implement some minor things like different file modes
(r,r+,w,w+,a,...) and options so it's possible to trigger errors, that
give more detail, but the basic functionality is included.
@Greg: Yes, I know that I still have to include some inline
documentation, on which problem it does solve :-) I'll do that before
the first version is released.
You can take a look at the sourcecode at:
http://www.php-tools.de/PEAR/Stream_Var/Var.phps
Download it, with examples from:
http://www.php-tools.de/PEAR/Stream_Var/Stream_var.zip
You can also take a look at the sourcecode of the examples at:
http://www.php-tools.de/PEAR/Stream_Var/examples/example.phps
http://www.php-tools.de/PEAR/Stream_Var/examples/example2.phps
The will not work on this server, as PHP4.3.2 is not installed :-( (I
already informed the hoster), but you can download the zip and test it
on your local machine.
So please send your feedback and comments, so I can include this in PEAR
as soon as possible :-)
Best regards,
Stephan