Documentation

Documentation

Packages

Application
Dynart

Namespaces

Dynart

Table of Contents

base_url()  : string
Returns with the `app.base_url` config value
url()  : string
Returns with a URL for the given URI
route_url()  : string
Returns with a URL for the given route
esc_html()  : string
Returns with a safe HTML string
esc_attr()  : string
Returns with a safe HTML attribute value
esc_attrs()  : string
Returns with a safe HTML attributes string
tr()  : string
Returns with a translated text

Functions

base_url()

Returns with the `app.base_url` config value

base_url() : string
Return values
string

The base URL

url()

Returns with a URL for the given URI

url(string $uri[, bool $withMTime = true ]) : string

For example, if your app.base_url is http://example.com and the given $uri is "/static/script.js", the result will be: http://example.com/static/script.js?123123123

The number at the end is the modification timestamp of the file. If the $withMTime parameter is false the result will not contain the question mark and the timestamp.

Parameters
$uri : string

The URI

$withMTime : bool = true

Are you need a modification time at the end?

Return values
string

The full URL

route_url()

Returns with a URL for the given route

route_url(string $route[, array<string|int, mixed> $params = [] ][, string $amp = '&amp;' ]) : string

Heavily depends on the configuration of the application.

For example, if the given $route is '/example-route', the $params is an associative array ['name' => 'joe'], you have a multi locale config, the app.use_rewrite set to true and app.base_url is 'http://example.com' then the result will be: 'http://example.com/en/example-route?name=joe'

Parameters
$route : string

The route

$params : array<string|int, mixed> = []

The HTTP query parameters for the route

$amp : string = '&amp;'

The ampersand symbol. The default is '&amp;' but you can change it to '&' if needed.

Tags
see
Router::url()
Return values
string

The full URL for the route

esc_html()

Returns with a safe HTML string

esc_html(string $text) : string

For example: if the $text is '<script>Evil script</script>' the result will be '&lt;script&gt;Evil script&lt;/script&gt;'

Parameters
$text : string

The text for escaping

Return values
string

The HTML escaped string

esc_attr()

Returns with a safe HTML attribute value

esc_attr(string $value) : string

For example: if the $value is '"something"' with the double quotes the result will be '&quot;something&quot;'

Parameters
$value : string

The value for escaping

Return values
string

The safe HTML attribute value

esc_attrs()

Returns with a safe HTML attributes string

esc_attrs(array<string|int, mixed> $attributes[, bool $startWithSpace = true ]) : string

For example, the following call:

esc_attrs(['name1' => 'value1', 'name2' = '"', 'name3']);

will return with 'name1="value1" name2="&quot;" name3'

Parameters
$attributes : array<string|int, mixed>
$startWithSpace : bool = true

should the result start with a space?

Return values
string

The HTML attributes string

tr()

Returns with a translated text

tr(string $id) : string

For example: if the application is configured with multi locale in the config.ini.php:

translation.all = en, hu
translation.default = en

The current locale is "en" and you added a translation directory with namespace "example" and the directory contains an en.ini with the following content:

hello = "Welcome {name}!"

Calling tr('example:hello', ['name' => 'Joe']) will return 'Welcome Joe!'

Parameters
$id : string

The ID of the text "namespace:text_id"

Tags
see
Translation
see
LocaleResolver
Return values
string

The translated text

Search results