<?php function tagWrap(string $tag, string $txt = '', ?callable $func = null): string { $txt = $func ? $func($txt) : $txt; if (!strlen($txt)) { return ''; } return sprintf('<%1$s>%2$s</%1$s>', $tag, $txt); } function underline($txt) { return "<u>$txt</u>"; } echo tagWrap('b', 'make me bold') . "\n"; echo tagWrap('b') . "\n"; echo tagWrap('b', func: fn() => 'sneak this text in') . "\n"; echo tagWrap('i', 'underline me too', "underline") . "\n"; echo tagWrap('i', 'encode \'me\'', "htmlentities") . "\n"; echo tagWrap('i', 'make me italic and quote me', fn($txt) => ""$txt"");
You have javascript disabled. You will not be able to edit any code.