Accepting Streams as parameters to PHP_FUNCTION()s is easy:

 1: PHP_FUNCTION(example_write)
 2: {
 3:     zval *zstream;    
 4:     php_stream *stream;
 5: 
 6:     if (FAILURE == zend_parse_parameters(
 7:             ZEND_NUM_ARGS() TSRMLS_CC,
 8:             "r", &zstream)) {
 9:         return;
10:     }
11: 
12:     php_stream_from_zval(stream, &zstream);
13: 
14:     php_stream_write(stream, "hello\n");
15: }
Note: You must NOT php_stream_close() a stream passed in from a script