Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Parse a URL and return its components
<?php parse_url(string $url, int $component = -1): int|string|array|null|false
<?php         }




        $data = trim(parse_url($connection->getRemoteAddress(), PHP_URL_HOST), '[]') . ': ' . $data . PHP_EOL;

        foreach ($socket->getConnections() as $connection) {

            $connection->write($data);

        }
<?php if (strpos($uri, '://') === false) {

    $uri = 'http://' . $uri;

}

$parts = parse_url($uri);



if (!$parts || !isset($parts['scheme'], $parts['host'])) {

    fwrite(STDERR, 'Usage error: required argument <host:port>' . PHP_EOL);
<?php         $original = $uri;

        if (\strpos($uri, '://') === false) {

            $uri = 'tcp://' . $uri;

            $parts = \parse_url($uri);

            if (isset($parts['scheme'])) {

                unset($parts['scheme']);

            }
<?php                 unset($parts['scheme']);

            }

        } else {

            $parts = \parse_url($uri);

        }



        if (!$parts || !isset($parts['host'])) {
<?php         $this->unix = \parse_url($this->getAddress(), \PHP_URL_PORT) === false;



        \stream_set_blocking($this->master, false);
<?php         $original = $uri;

        if (\strpos($uri, '://') === false) {

            $uri = 'tcp://' . $uri;

            $parts = \parse_url($uri);

            if (isset($parts['scheme'])) {

                unset($parts['scheme']);

            }
<?php                 unset($parts['scheme']);

            }

        } else {

            $parts = \parse_url($uri);

        }



        if (!$parts || !isset($parts['host'])) {
<?php             $uri = 'tls://' . $uri;

        }



        $parts = \parse_url($uri);

        if (!$parts || !isset($parts['scheme']) || $parts['scheme'] !== 'tls') {

            return Promise\reject(new \InvalidArgumentException(

                'Given URI "' . $uri . '" is invalid (EINVAL)',
<?php             $uri = 'tcp://' . $uri;

        }



        $parts = \parse_url($uri);

        if (!$parts || !isset($parts['scheme'], $parts['host'], $parts['port']) || $parts['scheme'] !== 'tcp') {

            return Promise\reject(new \InvalidArgumentException(

                'Given URI "' . $uri . '" is invalid (EINVAL)',
<?php         if (\substr($uri, -2) === ':0') {

            $parts = \parse_url(\substr($uri, 0, -2));

            if ($parts) {

                $parts['port'] = 0;

            }
<?php                 $parts['port'] = 0;

            }

        } else {

            $parts = \parse_url($uri);

        }
<?php         $uri = 'tcp://reactphp.org:80';

        $host = 'reactphp.org';

        $parts = parse_url($uri);



        $builder = new HappyEyeBallsConnectionBuilder($loop, $connector, $resolver, $uri, $host, $parts);
<?php         $uri = 'tcp://reactphp.org:80';

        $host = 'reactphp.org';

        $parts = parse_url($uri);



        $builder = new HappyEyeBallsConnectionBuilder($loop, $connector, $resolver, $uri, $host, $parts);
<?php         $uri = 'tcp://reactphp.org:80';

        $host = 'reactphp.org';

        $parts = parse_url($uri);



        $builder = new HappyEyeBallsConnectionBuilder($loop, $connector, $resolver, $uri, $host, $parts);
<?php         $uri = 'tcp://reactphp.org:80';

        $host = 'reactphp.org';

        $parts = parse_url($uri);



        $builder = new HappyEyeBallsConnectionBuilder($loop, $connector, $resolver, $uri, $host, $parts);