str::link($href, $text = null, $attr = array())

Generates an a tag

  • $href (string)
    The url for the a tag
  • $text (mixed)
    The optional text. If null, the url will be used as text
  • $attr (array)
    Additional attributes for the tag
  • return (string)
    the generated html

Example

<?php
echo str::link('https://getkirby.com');
echo str::link('https://getkirby.com', 'Visit our website');
echo str::link('https://getkirby.com', 'Visit our website', array(
  'class' => 'ajax-link',
));

Result:

<a href="https://getkirby.com">https://getkirby.com</a>
<a href="https://getkirby.com">Visit our website</a>
<a href="https://getkirby.com" class="ajax-link">Visit our website</a>

Is something missing or incorrect? Edit this page on Github…