Vesthelm Engine

2.1.4 User Guide

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: &lt;a href=&#039;test&#039;&gt;Test&lt;/a&gt;

Converting All Applicable Characters to HTML Entities

$string = $this->Sanitization->html("A 'quote' is bold");

echo $string; //Outputs: A &#039;quote&#039; is &lt;b&gt;bold&lt;/b&gt;

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...