PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

stream_bucket_append> <Streams
Last updated: Fri, 15 Aug 2008

view this page in

Stream Functions

Table of Contents



stream_bucket_append> <Streams
Last updated: Fri, 15 Aug 2008
 
add a note add a note User Contributed Notes
Stream Functions
kburkholder at earthasylum dot com
10-Mar-2008 11:43
I've developed a simple streams class to handle get, post and put requests (based on the documentation and user notes here).

The simplest example:

<?php
   
// a simple GET request:
   
include('eac_streams.class.php');
   
$http = new stream();
   
$result = ('http://www.domain.com/somepage.php');
?>

Along with that,  I have a curl class that does nearly the same thing.

http://www.kevinburkholder.com/sw_curl_stream.php

Hope it's useful. Any feedback is welcomed.
Thanks.

[note: cross-posted to curl page]
marcus at synchromedia dot co dot uk
16-Nov-2007 12:13
I can't find any real documentation on the quoted-printable-encode stream filter, but I've gathered info from several places. It seems there are 4 options that can be passed in the param array as in my other note on this subject:

line-length: integer, simply sets line length before a soft break is inserted
line-break-chars: Which char or chars to consider as a line break - note that "\r\n" will only match CRLF, not CR or LF, so make sure it matches your content.
binary: boolean, hex encodes all control chars, including spaces and line breaks, but leaves alphanumerics untouched
force-encode-first: Forcibly hex-encodes the first char on each line, even if it's alphanumeric. This is useful for avoiding corruption in some incompetent mail servers, like Exchange.
marcus at synchromedia dot co dot uk
30-Oct-2006 07:16
As this article says, there is no quoted_printable_encode function() in PHP: http://www.zend.com/manual/filters.convert.php

However there is a stream filter for quoted printable encoding. Here's an example function that produces output suitable for email and doesn't explicitly use external files (though it might do for strings over 2Mb due to the nature of the temp stream type):

<?php
function quoted_printable_encode($string) {
       
$fp = fopen('php://temp/', 'r+');
       
$params = array('line-length' => 70, 'line-break-chars' => "\r\n");
       
stream_filter_append($fp, 'convert.quoted-printable-encode', STREAM_FILTER_READ, $params);
       
fputs($fp, $string);
       
rewind($fp);
        return
stream_get_contents($fp);
}

echo
quoted_printable_encode(str_repeat("hello there ", 50)." a=1\r\n")."\n";
?>

The filter needs to be restricted to STREAM_FILTER_READ because by default it will get filtered both going into and out of the stream, and will thus get encoded twice.

It should be much faster than using a PHP implementation of the same thing, though note that this will only work in PHP 5.1+.
jausions at php dot net
16-May-2006 05:59
For the "notification" index of the $params for stream_context_set_params() function, a callable function is accepted. That is array(&$object, 'methodName') will also work.

stream_bucket_append> <Streams
Last updated: Fri, 15 Aug 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites