PHP Function Reference

PHP stream_get_wrappers() Function



The PHP stream_get_wrappers() function retrieves the list of registered streams available on the running system.

Syntax

stream_get_wrappers()

Parameters

No parameter is required.

Return Value

Returns an indexed array containing the name of all stream wrappers available on the running system.

Example: stream_get_wrappers() example

The example below shows the usage of stream_get_wrappers() function.

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

The output of the above code will be similar to:

Array
(
    [0] => https
    [1] => ftps
    [2] => compress.zlib
    [3] => php
    [4] => file
    [5] => glob
    [6] => data
    [7] => http
    [8] => ftp
    [9] => phar
)

Example: checking for the existence of a stream wrapper

Consider one more example where the existence of a given stream wrapper is checked on the running system.

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

The output of the above code will be:

compress.bzip2:// support not enabled.

❮ PHP Streams Reference