Skip to content

Kirby 4.5.0

Str::slug()

Convert a string to a safe version to be used in a URL

Str::slug(?string $string = null, ?string $separator = null, ?string $allowed = null, int|false $maxlength = 128): string

Parameters

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

Return type

string

Parent class

Kirby\Toolkit\Str