项目作者: 00F100

项目描述 :
Package to clean input content
高级语言: PHP
项目地址: git://github.com/00F100/fcphp-sinput.git
创建时间: 2018-08-13T23:39:47Z
项目社区:https://github.com/00F100/fcphp-sinput

开源协议:MIT License

下载


FcPhp Security Input

Package to clean input content

Build Status codecov

PHP Version Packagist Version Total Downloads

How to install

Composer:

  1. $ composer require 00f100/fcphp-sinput

or add in composer.json

  1. {
  2. "require": {
  3. "00f100/fcphp-sinput": "*"
  4. }
  5. }

How to use

  1. <?php
  2. use FcPhp\SInput\SInput;
  3. use FcPhp\SInput\Rules\AddSlashes;
  4. use FcPhp\SInput\Rules\HtmlEntities;
  5. use FcPhp\SInput\Rules\StripTags;
  6. $instance = new SInput();
  7. $instance->addRule('addslashes', new AddSlashes());
  8. $instance->addRule('htmlentities', new HtmlEntities());
  9. $instance->addRule('striptags', new StripTags());
  10. $content = [
  11. 'con"ntent' => 'value"',
  12. "ch'~ve" => "value'2",
  13. 'tag' => '<tag>content</tag>',
  14. ];
  15. $this->instance->executeRules(['striptags', 'htmlentities', 'addslashes'], $content);
  16. // Print:
  17. //
  18. // Array(
  19. // 'con"ntent' => 'value"',
  20. // 'ch\\\'~ve' => 'value\\\'2',
  21. // 'tag' => 'content'
  22. // )
  23. //
  24. echo $content;