PHP Doku:: Stream Funktionen - ref.stream.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzSonstige GrunderweiterungenStreamsStream Funktionen

Ein Service von Reinhard Neidl - Webprogrammierung.

Streams

<<streamWrapper::url_stat

set_socket_blocking>>


UnterSeiten:

Stream Funktionen

Inhaltsverzeichnis


3 BenutzerBeiträge:
- Beiträge aktualisieren...
marcus at synchromedia dot co dot uk
15.11.2007 16: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.10.2006 11: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
15.05.2006 22: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.



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)