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.
Funciones de Flujos
Tabla de contenidos
- set_socket_blocking — Alias de stream_set_blocking
- stream_bucket_append — Añade un recipiente a una cadena de recipientes
- stream_bucket_make_writeable — Devuelve un objeto recipiente desde una cadena de recipientes para operarar con él
- stream_bucket_new — Crear un nuevo recipiente para usarlo en el flujo actual
- stream_bucket_prepend — Añade un recipiente al principio de una cadena de recipientes
- stream_context_create — Crear un contexto de flujo
- stream_context_get_default — Recuperar el contexto de flujo predeterminado
- stream_context_get_options — Recuperar las opciones para un flujo/envoltura/contexto
- stream_context_get_params — Recuperar los parámetros de un contexto
- stream_context_set_default — Establecer el contexto de flujo predeterminado
- stream_context_set_option — Establece una opción para un flujo/envoltura/contexto
- stream_context_set_params — Establecer parámetros para un flujo/envoltura/contexto
- stream_copy_to_stream — Copia información desde un flujo a otro
- stream_encoding — Establecer el conjunto de caracteres para la codificación del flujo
- stream_filter_append — Enlaza un filtro a un flujo
- stream_filter_prepend — Enlaza un filtro a un flujo
- stream_filter_register — Registrar un filtro de flujo definido por el usuario
- stream_filter_remove — Elimina un filtro de un flujo
- stream_get_contents — Transfiere el resto de un flujo a una cadena
- stream_get_filters — Recuperar la lista de los filtros registrados
- stream_get_line — Obtiene una línea del recurso de flujo hasta un delimitador dado
- stream_get_meta_data — Recuperar meta-información o de cabecera de punteros a flujos/archivo
- stream_get_transports — Recuperar la lista de transportes de socket registrados
- stream_get_wrappers — Recupera la lista de los flujos registrados
- stream_is_local — Comprueba si un flujo es un flujo local
- stream_notification_callback — Una función de llamada de retorno para el parámetro de contexto de notificación
- stream_register_wrapper — Alias de stream_wrapper_register
- stream_resolve_include_path — Resuelve el nombre de archivo en la ruta incluida
- stream_select — Ejecuta el equivalente de la llamada al sistema select() sobre las matrices de flujos dadas con un tiempo de espera especificado por tv_sec y tv_usec
- stream_set_blocking — Establecer el modo bloqueo/no-bloqueo en un flujo
- stream_set_chunk_size — Establecer el tamaño de trozo de flujo
- stream_set_read_buffer — Establece el búfer de lectura de archivos en el flujo dado
- stream_set_timeout — Establecer un perido de tiempo de espera en un flujo
- stream_set_write_buffer — Establece el búfer para escritura de archivos en el flujo dado
- stream_socket_accept — Acepta una conexión sobre un socket creado por stream_socket_server
- stream_socket_client — Abrir una conexión de socket de dominio de Internet o Unix
- stream_socket_enable_crypto — Activa/desactiva la encriptación en un socket ya conectado
- stream_socket_get_name — Recuperar el nombre de los sockets locales o remotos
- stream_socket_pair — Crea un pareja de flujos de socket conectados e indistinguibles
- stream_socket_recvfrom — Recibir información de un socket, conectado o no
- stream_socket_sendto — Envía un mensaje a un socket, ya esté conectado o no
- stream_socket_server — Crear un socket de servidor de dominio de Internet o de Unix
- stream_socket_shutdown — Cerrar una conexión full-duplex
- stream_supports_lock — Indica si el flujo soporta bloqueo
- stream_wrapper_register — Registra una envoltura de URL implementada como una clase de PHP
- stream_wrapper_restore — Restablece una envoltura incluida que se dejó de registrar previamente
- stream_wrapper_unregister — Deja de registrar una envoltura de URL
marcus at synchromedia dot co dot uk ¶
5 years ago
marcus at synchromedia dot co dot uk ¶
6 years ago
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 ¶
7 years ago
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.
