array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.stream-get-wrappers.php', 1 => 'stream_get_wrappers', ), 'up' => array ( 0 => 'ref.stream.php', 1 => 'Stream 函数', ), 'prev' => array ( 0 => 'function.stream-get-transports.php', 1 => 'stream_get_transports', ), 'next' => array ( 0 => 'function.stream-is-local.php', 1 => 'stream_is_local', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/stream/functions/stream-get-wrappers.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(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
// 检查是否存在 bzip2 流包装器
if (in_array('compress.bzip2', stream_get_wrappers())) {
echo 'compress.bzip2:// support enabled.';
} else {
echo 'compress.bzip2:// support not enabled.';
}
?>