PHP code example of thinktomorrow / url
1. Go to this page and download the library: Download thinktomorrow/url library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once ('vendor/autoload.php' );
thinktomorrow / url example snippets
\Thinktomorrow\Url\Url::fromString('https://example.com' );
\Thinktomorrow\Url\Url::fromString('https://example.com' )->getScheme();
\Thinktomorrow\Url\Url::fromString('https://example.com' )->getHost();
\Thinktomorrow\Url\Url::fromString('https://example.com:9000' )->getPort();
\Thinktomorrow\Url\Url::fromString('https://example.com/foo/bar' )->getPath();
\Thinktomorrow\Url\Url::fromString('https://example.com?foo=bar' )->getQuery();
\Thinktomorrow\Url\Url::fromString('https://example.com#foobar' )->getHash();
Url::fromString('example.com' )->secure()->get();
Url::fromString('example.com' )->nonSecure()->get();
Url::fromString('https://example.com' )->nonSecure()->get();
Url::fromString('http://example.com/foobar' )
->setCustomRoot(Root::fromString('https://newroot.be' ))
->get();
Url::fromString('http://example.com/foobar' )
->localize('en' )
->get();
Url::fromString('http://example.com/en/foobar' )
->localize('fr' , ['en' ,'fr' ])
->get();
Url::fromString('http://example.com/en/foobar' )
->localize(null , ['en' ,'fr' ])
->get();