Text helper

Table of Contents 


Helper offering several methods of handling character strings.


Converts text into a string that can be used as a file name.

Method signature:

filenamize(string $filename, bool $hyphenSpaces=true, bool $lowercase=true) : string


  • $filename: Text to convert.
  • $hyphenSpaces: true to replace spaces with dashes.
  • $lowercase: true to make text all lowercase.

Return value: The file name.


Converts text so that it can be used in a URL.

Method signature:

urlize(?string $txt, bool $avoidUnderscores=true) : string


  • $txt: Text to convert.
  • $avoidUnderscores: true to replace underscores with dashes.

Return value: The converted text.


This method checks whether an HTML feed is syntactically correct.

Method signature:

isValidHtmlSyntax(string $html) : bool

Parameter: The HTML stream to be validated.

Return value: true if the HTML stream is valid, false otherwise.


This method transforms an HTML stream into plain text.

Method signature:

htmlToText(string $html, bool $cleanup=false) : string


  • $html: HTML stream to convert.
  • $cleanup: true to remove the content of <blockquote>, <pre> and <code> tags.

Return value: Plain text generated from HTML.


This method indicates whether a character string encoded in UTF-8 contains only characters compatible with the encoding supplied as a parameter.

Method signature:

encodingCompatible(string $text, string $encoding) : bool


  • $text: The text to analyze.
  • $encoding: The encoding to use.

Return value: Return value : True if the text contains only characters compatible with the character encoding supplied in parameter.

Previous: Term helper
Next: Timer helper

Table of Contents