Package to clean input content
Package to clean input content
Composer:
$ composer require 00f100/fcphp-sinput
or add in composer.json
{
"require": {
"00f100/fcphp-sinput": "*"
}
}
<?php
use FcPhp\SInput\SInput;
use FcPhp\SInput\Rules\AddSlashes;
use FcPhp\SInput\Rules\HtmlEntities;
use FcPhp\SInput\Rules\StripTags;
$instance = new SInput();
$instance->addRule('addslashes', new AddSlashes());
$instance->addRule('htmlentities', new HtmlEntities());
$instance->addRule('striptags', new StripTags());
$content = [
'con"ntent' => 'value"',
"ch'~ve" => "value'2",
'tag' => '<tag>content</tag>',
];
$this->instance->executeRules(['striptags', 'htmlentities', 'addslashes'], $content);
// Print:
//
// Array(
// 'con"ntent' => 'value"',
// 'ch\\\'~ve' => 'value\\\'2',
// 'tag' => 'content'
// )
//
echo $content;