php_stream * stream = php_stream_open_wrapper( "http: / /www.php.net", "rb", REPORT_ERRORS, NULL); if (stream) {while(!php_stream_eof(stream)) {char buf[1024]; if (php_stream_gets(stream, buf, sizeof(buf))) {printf(buf);} else {break;}} php_stream_close(stream);}
Using streams is very much like using ANSI stdio functions. The main difference is in how you obtain the stream handle to begin with. In most cases, you will use php_stream_open_wrapper() to obtain the stream handle. This function works very much like fopen, as can be seen from the example below: