文字

stream_get_wrappers

(PHP 5)

stream_get_wrappers获取已注册的流类型

说明

array stream_get_wrappers ( void )

获取在当前运行系统中已经注册并可使用的流类型列表。

返回值

返回一个索引数组,该数组里包含了当前运行系统中可使用的流类型的名称。

范例

Example #1 stream_get_wrappers() 例子

<?php
print_r
( stream_get_wrappers ());
?>

以上例程的输出类似于:

Array
(
    [0] => php
    [1] => file
    [2] => http
    [3] => ftp
    [4] => compress.bzip2
    [5] => compress.zlib
)

Example #2 检查一个流类型是否存在

<?php
// check for the existence of the bzip2 stream wrapper
if ( in_array ( 'compress.bzip2' stream_get_wrappers ())) {
    echo 
'compress.bzip2:// support enabled.' ;
} else {
    echo 
'compress.bzip2:// support not enabled.' ;
}
?>

参见

  • stream_wrapper_register()
上一篇: 下一篇: