Open In App

PHP | stream_get_transports() Function

Last Updated : 11 Jul, 2025
Summarize
Comments
Improve
Suggest changes
Share
Like Article
Like
Report
The stream_get_transports() function is an inbuilt function in PHP which is used to get the list of registered socket transports. This function returns the indexed array containing the name of all available socket. Syntax:
array stream_get_transports( void )
Parameters: This function does not accept any parameter. Return Value: This function returns an array containing the name of all available socket transport. Below programs illustrate the stream_get_transports() function in PHP: Program 1: PHP
<?php

// PHP program to illustrate
// stream_get_transports function

print_r(stream_get_transports());
?>
Output:
Array
(
    [0] => tcp
    [1] => udp
    [2] => unix
    [3] => udg
    [4] => ssl
    [5] => tls
    [6] => tlsv1.0
    [7] => tlsv1.1
    [8] => tlsv1.2
)
Program 2: Program to check transports are available or not. php
<?php

// PHP program to illustrate
// stream_get_transports function

$wrapper = array (
    'tcp',
    'unix',
    'file',
    'ssl',
    'GFG'
);

// Checking socket transport enabled or not
foreach ($wrapper as &$gfg) {
    if (in_array($gfg, stream_get_transports())) {
        echo $gfg . ': Enabled' . "\n";
    } else {
        echo $gfg . ": Not Enabled" . "\n";
    }
}

?>
Output:
tcp: Enabled
unix: Enabled
file: Not Enabled
ssl: Enabled
GFG: Not Enabled
Reference: https://www.php.net/manual/en/function.stream-get-transports.php

Similar Reads