The class StringAssistant provides static methods to manipulate stings.
|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:
use APF\tools\string\StringAssistant; $sanitizedString = StringAssistant::escapeSpecialCharacters($_REQUEST['some-parameter']); $captchaChallenge = StringAssistant::generateCaptchaString(5); $entityEncoded = StringAssistant::encodeCharactersToHTML('email@example.com');