Parsers

Apostrophes

You can escape apostrophes in text with apos method. It is useful if you're printing your text inside of Javascript string.


Html::apos("Don't stop, this is your text.");
// will return: Don\'t stop, this is your text.

And there is other method for the same thing, just for quotes. It is useful if you're printing your text inside of HTML value attributes or any other other attributes.


Html::quotes('They said: "Enough is enough");
// will return: They said: "Enough is enough"

HTML tags

If you want to display HTML tags on your page, then you need to replace all signs "<" and ">" to HTML format. Use Html::tags() method to do that. This will not strip tags. If you want to remove tags, then use strip_tags() method.


Html::tags('This is your paragraph: <p>Lorem ipsum</p>');
// will return: This is your paragraph: &lt;p&gt;Lorem ipsum&lt;/p&gt;

Truncate

To truncate long text, use Html::truncate() method.

Definition:


Html::truncate(string $longTextint $length 80string $suffix '...'bool $breakWords falsebool $middle false)


$longText 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.';

echo 
Html::truncate($longText40'... and so on.');
// will print: Lorem ipsum dolor sit... and so on.
UrlCLI