Skip to content

Kirby 5.1.1

Html::tel()

Generates an <a> tag for a phone number

Html::tel(string $tel, string|array|null $text = null, array $attr = [ ]): string

Parameters

Name Type Default Description
$telrequired string no default value The phone number
$text stringorarrayornull null The optional text; if null, the phone number will be used as text
$attr array [ ] Additional attributes for the tag

Return type

string

The generated HTML

Parent class

Kirby\Cms\Html inherited from Kirby\Toolkit\Html

Limitations

The Html::link() method strips out any non-numeric characters in the provided phone number (except the plus sign for international phone numbers). This is done to ensure a safe and reliable behavior of the resulting link.

If you need to add parameters or formatting to the tel URI (according to RFC 3966), please use the Html::link() method that otherwise works the same:

Html::link('tel:+1-416-123-4567;ext=890', '+1 416-123-4567 ext. 890');