Documentation
Text helper
Table of Contents ▼
Presentation
Helper offering several methods of handling character strings.
filenamize()
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
Parameters:
- $filename: Text to convert.
- $hyphenSpaces: true to replace spaces with dashes.
- $lowercase: true to make text all lowercase.
Return value: The file name.
urlize()
Converts text so that it can be used in a URL.
Method signature:
urlize(?string $txt, bool $avoidUnderscores=true) : string
Parameters:
- $txt: Text to convert.
- $avoidUnderscores: true to replace underscores with dashes.
Return value: The converted text.
isValidHtmlSyntax()
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.
htmlToText()
This method transforms an HTML stream into plain text.
Method signature:
htmlToText(string $html, bool $cleanup=false) : string
Parameters:
- $html: HTML stream to convert.
- $cleanup: true to remove the content of <blockquote>, <pre> and <code> tags.
Return value: Plain text generated from HTML.
encodingCompatible()
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
Parameters:
- $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
- Migration : How to upgrade from Temma 1.x to version 2
- Installation : Download Temma and install it to start your web project
- Configuration : All the configuration directives of the etc/temma.json file and the optional environment variables
- External libraries : How to use external function libraries
- Routing : Temma's default routing system, and advanced routing
- Log : Use of the log system, management by criticality levels
- Controllers : Essential parts of your web application
- Views : Smarty templates or JSON/CSV/RSS/iCal/INI exports
- Dependency injection : The backbone of your application developments
- Sessions : Extension of user sessions managed by PHP
- Data sources : Unified data access management
- Model : How to use DAOs to access databases
- Execution flow : How to manage the execution flow, between plugins and the controller
- Plugins : How to use plugins, and create your own plugins to modularize your code
- Attributes : How to filter access to controllers and actions
- Command-line interface : To create executable scripts on the command line, automatically initialized by Temma
-
Helpers :
Items offered by Temma to help you in various circumstances
- Command-line scripts
-
Controller + plugin
- Auth : Controller and plugin to manage user authentication
- Plugins
- Attributes
-
Utility objects
- ANSI : To format texts written to standard output
- BaseConvert : To do digital base conversions
- DataFilter : To filter and validate data
- Email : To send emails
- HTMLCleaner : To clean up an HTML stream coming from a WYSIWYG editor
- IniExport : To export data in INI format
- Json : To read JSON streams that may contain comments
- Lock : To lock access to a file, or the execution of the current PHP script
- Registry : To properly store global variables
- Smarty : To process Smarty templates outside the view
- Term : Terminal management (TTY)
- Text : Different treatments on character strings
- Timer : To manage stopwatches