CakeFest 2024: The Official CakePHP Conference

stream_get_wrappers

(PHP 5, PHP 7, PHP 8)

stream_get_wrappers获取已注册的流类型

说明

stream_get_wrappers(): array

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

参数

此函数没有参数。

返回值

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

示例

示例 #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
)

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

<?php
// 检查是否存在 bzip2 流包装器
if (in_array('compress.bzip2', stream_get_wrappers())) {
echo
'compress.bzip2:// support enabled.';
} else {
echo
'compress.bzip2:// support not enabled.';
}
?>

参见

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top