PhpSanitization
v1.0.13
Simple PHP Sanitization Class
This is a simple class that can verify and clean values to assure they are valid.
It can take a given string and remove or encode certain types of text values, so it can be displayed in Web pages lowering the risk of being used to perform security attacks.
The class can also sanitize arrays of data by processing the array values one by one.
$ composer require phpsanitization/phpsanitizationinclude_once 'vendor/autoload.php';
use PhpSanitizationPhpSanitizationSanitization;
use PhpSanitizationPhpSanitizationUtils;
$sanitizer = new Sanitization(new Utils);echo $sanitizer->useSanitize("<script>alert('xss');</script>");echo $sanitizer->useEscape("SELECT * FROM `users` WHERE `username` = 'admin';");echo $sanitizer->useTrim(" This is a text ");echo $sanitizer->useHtmlEntities("<script>alert('This is js code');</script>");echo $sanitizer->useFilterVar("This is a string");echo $sanitizer->useStripTags("<script>alert('This is js code');</script>");echo $sanitizer->useStripSlashes("C:UsersFarisMusic");echo $sanitizer->useHtmlSpecialChars("<script>alert('This is js code');</script>");$sanitizer->setData("This is data");echo $sanitizer->getData();echo $sanitizer->useStrReplace("text", "", "this is a text");echo $sanitizer->usePregReplace("/([A-Z])w+/", "This is a Text");echo $sanitizer->validateEmail("[email protected]") ? "true" : "false";echo $sanitizer->isValid("127.0.0.1", FILTER_VALIDATE_IP) ? "true" : "false";echo $sanitizer->isEmpty($variable) ? "true" : "false";echo $sanitizer->isAssociative($array) ? "true" : "fale";echo $sanitizer->callback(function () {
return "text";
});The documentation for PhpSanitization is available here
Please have a look at CHANGELOG.md.
Please have a look at CONTRIBUTING.md.
Please have a look at CODE_OF_CONDUCT.md.
This package is licensed using the MIT License.
Please have a look at LICENSE.md.
Copyright (c) FarisCode - 2021