Url


The url library provides useful methods for validating and parsing urls.

valid()

Returns true or false depending on whether the passed string is a valid http URL.

$this->zajlib->url->valid($url, $allow_spaces = true)

@param string $url The url to be parsed
@param boolean $allow_spaces Allow spaces in query string. This will allow spaces in query string, but also in the url. True url-encoded strings should not require this since spaces are %20.
@return bool True if a valid url. False otherwise.

get_domain()

Returns the domain without any subdomains for the given url. For example, for foo.bar.www.youtube.com it will return youtube.com.

$this->zajlib->url->get_domain($url)

@param string $url The url to parse.
@return string The domain portion of the url.

get_subdomain()

Returns the subdomain, but excludes www. This is useful because users usually think www.news.domain.com is the same as news.domain.com and domain.com is the same as www.domain.com.

$this->zajlib->url->get_subdomain($url)

@param string $url The url to parse.
@return string The subdomain portion of the url.

friendly()

Generates a friendly url based on an input string.

$this->zajlib->url->friendly($title)

@param string $title Any string such as a name or title.
@return string The string converted to a url-friendly format (no accents, trimmed, no spaces)

querymode()

Get ready for query string by adding a ? or & to the url.

$this->zajlib->url->querymode($url)

@param string $url Any url.
@return string Will return a url that is definitely ready to append a query string.

Outlast Web & Mobile Development (c) 2023 | Privacy Policy |