Re: Streams
| From: | Ben Chivers | Date: | Thu, 06 May 2004 10:51:17 +0000 |
| Subject: | Re: Streams | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-598@lists.php.net to get a copy of this message | ||
Hi,
Thank you very much for your reply. Much appreciated.
What I want to do is create a php extension which parses php code to the interpreter. e.g. the php
script using the php extension will something like this:
<?php
passCode("echo('Hello World';");
?>
The extension will look something like this:
PHP_FUNCTION
{
char code[128] = "echo('Hello World');";
size_t bt;
php_stream * phpStream = php_stream_open_wrapper("php://stdout", "w",
REPORT_ERRORS, NULL);
if (stream)
{
zend_printf("Stream Connected");
bt = php_stream_write(phpStream, code, sizeof(code));
php_stream_close(phpStream);
}
else
{
zend_printf("Stream Connection Error");
}
}
This function would pass the code "echo('Hello World');" to PHP and execute it.
What I am having problems is, is retrieving the output of this function e.g. "Hello
World". But the problem with PHP is that it's unidirectional (oneway) from what I know.
Is there a way to read the output from PHP? What would be the best way of doing that? Would it
have anything to do with flushing?
Thank you very much for your time. Any help with this would be most appreciated. I wanted to ask
you, as you are a developer for PHP, and you developed the php streaming for php extensions and c++
programs.
I hope it makes sense.
Many Regards,
Ben Chivers