Skip to content

Kirby 5.1.1

Url::slug()

Convert a string to a safe version to be used in a URL, obeying the slugs.maxlength option

Url::slug(string $string = null, string $separator = null, string $allowed = null, int $maxlength): string

Parameters

Name Type Default Description
$string string null The unsafe string
$separator string null To be used instead of space and
other non-word characters.
$allowed string null List of all allowed characters (regex)
$maxlengthrequired int no default value The maximum length of the slug

Return type

string

The safe string

Parent class

Kirby\Cms\Url