PHP | stream_get_wrappers() Function
Last Updated :
17 Dec, 2018
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
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
$wrapper = array (
'https' ,
'http' ,
'file' ,
'data' ,
'GFG'
);
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
Share your thoughts in the comments
Please Login to comment...