Sanitization Class¶
The Sanitization class provides functions to sanitize data.
Calling the Sanitization Class¶
$Sanitization = $this->Sanitization;
Replacing Bad Characters in a String¶
//allowed characters A-Za-z0-9_-
$bad_string = 'Vesthelm$$$';
$new_string = $this->Sanitization->replace($bad_string, '-'); //$new_string will be: Vesthelm---
Replacing Bad Characters in an Email¶
$bad_email = 'vesthelm^^^@vesthelm.com';
$new_email = $this->Sanitization->email($bad_email, ''); //$new_email will be: vesthelm@vesthelm.com
Converting Special Characters to HTML Entities¶
$string = $this->Sanitization->specchars("<a href='test'>Test</a>");
echo $string; //Outputs: <a href='test'>Test</a>
Converting All Applicable Characters to HTML Entities¶
$string = $this->Sanitization->html("A 'quote' is bold");
echo $string; //Outputs: A 'quote' is <b>bold</b>
Getting Valid Class Name¶
$class_name = $this->Sanitization->cls('bulletin_board_bulletin');
echo $class_name; //Outputs: Bulletin_Board_Bulletin
Truncating a String¶
$string = $this->Sanitization->truncate('Vesthelm', 3, '...');
echo $string; //Outputs: Vest...