PHP | stream_get_wrappers() Function
The stream_get_wrappers() function is an inbuilt function in PHP which is used to get the list of registered streams available on the running system.
Syntax:
array stream_get_wrappers( void )
Parameters: This function does not accept any parameter.
Return Value: The function returns an array containing the name of all available streams.
Below programs illustrate the stream_get_wrappers() function in PHP:
Program 1:
<?php // PHP program to illustrate // stream_get_wrappers function print_r(stream_get_wrappers()); ?> |
Output:
Array ( [0] => https [1] => ftps [2] => compress.zlib [3] => php [4] => file [5] => glob [6] => data [7] => http [8] => ftp [9] => phar )
Program 2: Program to check the given streams are available or not.
<?php // PHP program to illustrate // stream_get_wrappers function $wrapper = array ( 'https' , 'http' , 'file' , 'data' , 'GFG' ); // Checking stream wrapper enabled or not foreach ( $wrapper as & $gfg ) { if (in_array( $gfg , stream_get_wrappers())) { echo $gfg . ': Enabled' . "\n" ; } else { echo $gfg . ": Not Enabled" . "\n" ; } } ?> |
Output:
https: Enabled http: Enabled file: Enabled data: Enabled GFG: Not Enabled
Reference: http://php.net/manual/en/function.stream-get-wrappers.php