PHP code example of ddobren / filterguard
1. Go to this page and download the library: Download ddobren/filterguard library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ddobren / filterguard example snippets
// Including FilterGuard library
izing a string
$dirtyString = '<script>alert("XSS attack!");</script>';
$cleanString = FilterGuard::sanitizeString($dirtyString);
var_dump($cleanString);
// Sanitizing an integer
$dirtyInteger = '123';
$cleanInteger = FilterGuard::sanitizeInteger($dirtyInteger);
var_dump($cleanInteger);
// Sanitizing a float
$dirtyFloat = '12.34xyz';
$cleanFloat = FilterGuard::sanitizeFloat($dirtyFloat);
var_dump($cleanFloat);
// Sanitizing a boolean value
$dirtyBool = true;
$cleanBool = FilterGuard::sanitizeBoolean($dirtyBool);
var_dump($cleanBool);
// Sanitizing an array
$dirtyArray = ['<script>alert("XSS attack!");</script>', '123abc', '12.34xyz'];
$cleanArray = FilterGuard::sanitizeArray($dirtyArray);
var_dump($cleanArray);
// Sanitizing an object
$dirtyObject = (object) ['dirtyString' => '<script>alert("XSS attack!");</script>'];
$cleanObject = FilterGuard::sanitizeObject($dirtyObject);
var_dump($cleanObject);
// Sanitizing an auto
$dirtyValue = '<script>alert("XSS attack!");</script>';
$cleanValue = FilterGuard::sanitizeAuto($dirtyValue);
var_dump($cleanValue);