StringAssistant

The class StringAssistant provides static methods to manipulate stings.

Method Description
escapeSpecialCharacters() Strips special characters that can be problematical during saving data to a database or while displaying them in form controls.
replaceSpecialCharacters() Replaces characters that are not allowed for files names and returns a sanitized string.
encodeCharactersToHTML() Encodes a string into HTML entities.
generateCaptchaString() Generates a string, that can be used as a captcha check string.

Using the above methods is as follows:

PHP code
use APF\tools\string\StringAssistant; $sanitizedString = StringAssistant::escapeSpecialCharacters($_REQUEST['some-parameter']); $captchaChallenge = StringAssistant::generateCaptchaString(5); $entityEncoded = StringAssistant::encodeCharactersToHTML('foo@bar.com');

Comments

Do you want to add a comment to the article above, or do you want to post additional hints? So please click here. Comments already posted can be found below.
There are no comments belonging to this article.