php:// 访问各个输入/输出流(I/O streams)
php://stdin是只读的,php://stdout和php://stderr是只写的。
1、php://input 访问请求数据的只读流。POST请求的情况下,使用PHP:、、input代替$HTTP_RAW_POST_DATA,因为他不依赖于特定的php.ini指令。 enctype="multipart/from-data"的时候php://input 无效Note:在 PHP 5.6 之前php://input打开的数据流只能读取一次;
数据流不支持 seek(定位) 操作。
2、php://output
php://output是一个只写的数据流, 允许你以print和echo一样的方式 写入到输出缓冲区。
3、php://filter
php://filter是一种元封装器, 设计用于数据流打开时的筛选过滤应用。 这对于一体式(all-in-one)的文件函数非常有用,类似readfile()、file()和file_get_contents(), 在数据流内容读取之前没有机会应用其他过滤器。
Example #1php://temp/maxmemory
这个可选选项允许设置 php://temp 开始使用临时文件前的最大内存限制。
// Set the limit to 5 MB.
$fiveMBs=5*1024*1024;
$fp=fopen("php://temp/maxmemory:$fiveMBs",'r+');
fputs($fp,"hello\n");
// Read what we have written.
rewind($fp);
echo
stream_get_contents($fp);
?>Example #2php://filter/resource=这个参数必须位于 php://filter 的末尾,并且指向需要过滤筛选的数据流。
/* 这简单等同于:
readfile("http://www.example.com");
实际上没有指定过滤器 */
readfile("php://filter/resource=http://www.example.com");
?>
$http_response_header—HTTP 响应头
格式化请求头信息
//输出结果
获取请求头信息
if (!function_exists('getallheaders')) {
function getallheaders() {
foreach ($_SERVER as $name => $value) {
if (substr($name, 0, 5) == 'HTTP_') {
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
}
}
return $headers;
}
}