(PHP 5, PHP 7, PHP 8)
stream_get_wrappers — 检索已注册流的列表
此函数没有参数。
返回一个索引数组,其中包含正在运行的系统上所有可用流封装器的名称。
示例 #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
// 检查 compress.bzip2 流封装器是否存在
if (in_array('compress.bzip2', stream_get_wrappers())) {
echo 'compress.bzip2:// 支持已启用。';
} else {
echo 'compress.bzip2:// 支持未启用。';
}
?>