00f100/fcphp-sinput

There is no license information available for the latest version (0.1.0) of this package.

Package to clean input content

0.1.0 2018-08-14 02:31 UTC

This package is auto-updated.

Last update: 2024-11-18 05:47:46 UTC


README

Package to clean input content

Build Status codecov

PHP Version Packagist Version Total Downloads

How to install

Composer:

$ composer require 00f100/fcphp-sinput

or add in composer.json

{
    "require": {
        "00f100/fcphp-sinput": "*"
    }
}

How to use

<?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&quot;ntent' => 'value&quot;',
//      'ch\\\'~ve' => 'value\\\'2',
//      'tag' => 'content'
//  )
//
echo $content;