文字

Stream 函数

Table of Contents

  • set_socket_blocking — 别名 stream_set_blocking
  • stream_bucket_append — Append bucket to brigade
  • stream_bucket_make_writeable — Return a bucket object from the brigade for operating on
  • stream_bucket_new — Create a new bucket for use on the current stream
  • stream_bucket_prepend — Prepend bucket to brigade
  • stream_context_create — 创建资源流上下文
  • stream_context_get_default — Retrieve the default stream context
  • stream_context_get_options — 获取资源流/数据包/上下文的参数
  • stream_context_get_params — Retrieves parameters from a context
  • stream_context_set_default — Set the default stream context
  • stream_context_set_option — 对资源流、数据包或者上下文设置参数
  • stream_context_set_params — Set parameters for a stream/wrapper/context
  • stream_copy_to_stream — Copies data from one stream to another
  • stream_encoding — 设置数据流的字符集
  • stream_filter_append — Attach a filter to a stream
  • stream_filter_prepend — Attach a filter to a stream
  • stream_filter_register — Register a user defined stream filter
  • stream_filter_remove — 从资源流里移除某个过滤器
  • stream_get_contents — 读取资源流到一个字符串
  • stream_get_filters — 获取已注册的数据流过滤器列表
  • stream_get_line — 从资源流里读取一行直到给定的定界符
  • stream_get_meta_data — 从封装协议文件指针中取得报头/元数据
  • stream_get_transports — 获取已注册的套接字传输协议列表
  • stream_get_wrappers — 获取已注册的流类型
  • stream_is_local — Checks if a stream is a local stream
  • stream_notification_callback — A callback function for the notification context parameter
  • stream_register_wrapper — 别名 stream_wrapper_register
  • stream_resolve_include_path — Resolve filename against the include path
  • stream_select — Runs the equivalent of the select() system call on the given arrays of streams with a timeout specified by tv_sec and tv_usec
  • stream_set_blocking — 为资源流设置阻塞或者阻塞模式
  • stream_set_chunk_size — 设置资源流区块大小
  • stream_set_read_buffer — Set read file buffering on the given stream
  • stream_set_timeout — Set timeout period on a stream
  • stream_set_write_buffer — Sets write file buffering on the given stream
  • stream_socket_accept — 接受由 stream_socket_server 创建的套接字连接
  • stream_socket_client — Open Internet or Unix domain socket connection
  • stream_socket_enable_crypto — Turns encryption on/off on an already connected socket
  • stream_socket_get_name — 获取本地或者远程的套接字名称
  • stream_socket_pair — 创建一对完全一样的网络套接字连接流
  • stream_socket_recvfrom — Receives data from a socket, connected or not
  • stream_socket_sendto — Sends a message to a socket, whether it is connected or not
  • stream_socket_server — Create an Internet or Unix domain server socket
  • stream_socket_shutdown — Shutdown a full-duplex connection
  • stream_supports_lock — Tells whether the stream supports locking.
  • stream_register_wrapper — 注册一个用 PHP 类实现的 URL 封装协议
  • stream_wrapper_restore — Restores a previously unregistered built-in wrapper
  • stream_wrapper_unregister — Unregister a URL wrapper

用户评论:

[#1] marcus at synchromedia dot co dot uk [2007-11-15 15:13:33]

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.

[#2] marcus at synchromedia dot co dot uk [2006-10-30 10:16:14]

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+.

[#3] jausions at php dot net [2006-05-15 20:59:54]

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.

上一篇: 下一篇: