PHP Function Reference

PHP stream_get_filters() Function



The PHP stream_get_filters() function retrieves the list of registered filters on the running system.

Syntax

stream_get_filters()

Parameters

No parameter is required.

Return Value

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

Example: stream_get_filters() example

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

<?php
$streamlist = stream_get_filters();
print_r($streamlist);
?>

The output of the above code will be similar to:

Array
(
    [0] => zlib.*
    [1] => string.rot13
    [2] => string.toupper
    [3] => string.tolower
    [4] => convert.*
    [5] => consumed
    [6] => dechunk
    [7] => convert.iconv.*
)

Example: checking for the existence of a stream filter

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

<?php
//checking the existence of dechunk stream filter
if (in_array('dechunk', stream_get_filters())) {
  echo 'dechunk filter is available.';
} else {
  echo 'dechunk support is not available.';
}
?>

The output of the above code will be:

dechunk filter is available.

❮ PHP Streams Reference