parse_url

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     public function getFromRefererUrlQueryString($url, $key, $default = null)

    {

        $parsedUrl = parse_url($url);

        $query = [];



        if (isset($parsedUrl['query'])) {
<?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()
<?php         $url = preg_replace('#^((?:pdo_)?sqlite3?):///#', '$1://localhost/', $params['url']);

        assert(is_string($url));



        $url = parse_url($url);



        if ($url === false) {

            throw new Exception('Malformed parameter "url".');
<?php     {

        $terminalWidth = $this->getTerminalWidth();



        $url = parse_url($request['url'], PHP_URL_PATH) ?: '/';

        $duration = number_format(round($request['duration'], 2), 2, '.', '');



        $memory = isset($request['memory'])
<?php             ? sprintf('%s?token=%s', static::$url, $token)

            : $defaultUrl;



        parse_str(parse_url($url, PHP_URL_QUERY) ?: '', $query);



        if (static::$redirect) {

            $query = array_merge($query, ['redirect' => static::$redirect]);