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     protected function replaceBaseUrl($uri, $url)

    {

        $parsed = parse_url($url);



        return $uri

            ->withScheme($parsed['scheme'])
<?php     {

        $uri = $app->make('config')->get('app.url', 'http://localhost');



        $components = parse_url($uri);



        $server = $_SERVER;
<?php             'html' == $format => HtmlDumper::register($basePath, $compiledViewPath),

            'cli' == $format => CliDumper::register($basePath, $compiledViewPath),

            'server' == $format => null,

            $format && 'tcp' == parse_url($format, PHP_URL_SCHEME) => null,

            default => in_array(PHP_SAPI, ['cli', 'phpdbg']) ? CliDumper::register($basePath, $compiledViewPath) : HtmlDumper::register($basePath, $compiledViewPath),

        };

    }
<?php $publicPath = getcwd();



$uri = urldecode(

    parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) ?? ''

);
<?php     protected function allSubdomainsOfApplicationUrl()

    {

        if ($host = parse_url($this->app['config']->get('app.url'), PHP_URL_HOST)) {

            return '^(.+\.)?'.preg_quote($host).'$';

        }

    }
<?php         if (! is_null($fragment = parse_url($uri, PHP_URL_FRAGMENT))) {

            $uri = preg_replace('/#.*/', '', $uri);

        }
<?php     {

        $url = preg_replace('#^(sqlite3?):///#', '$1://null/', $url);



        $parsedUrl = parse_url($url);



        if ($parsedUrl === false) {

            throw new InvalidArgumentException('The database configuration URL is malformed.');
<?php             return false;

        }



        if ($url = parse_url($value, PHP_URL_HOST)) {

            try {

                $records = $this->getDnsRecords($url.'.', DNS_A | DNS_AAAA);
<?php         $response = new RedirectResponse('foo.bar');



        $response->withFragment('foo');

        $this->assertSame('foo', parse_url($response->getTargetUrl(), PHP_URL_FRAGMENT));



        $response->withFragment('#bar');

        $this->assertSame('bar', parse_url($response->getTargetUrl(), PHP_URL_FRAGMENT));
<?php         $this->assertSame('foo', parse_url($response->getTargetUrl(), PHP_URL_FRAGMENT));



        $response->withFragment('#bar');

        $this->assertSame('bar', parse_url($response->getTargetUrl(), PHP_URL_FRAGMENT));



        $response->withoutFragment();

        $this->assertNull(parse_url($response->getTargetUrl(), PHP_URL_FRAGMENT));
<?php         $this->assertSame('bar', parse_url($response->getTargetUrl(), PHP_URL_FRAGMENT));



        $response->withoutFragment();

        $this->assertNull(parse_url($response->getTargetUrl(), PHP_URL_FRAGMENT));

    }



    public function testInputOnRedirect()