Skip to content

数据过滤库,数据类型处理,SQL注入,XSS过滤等

License

Notifications You must be signed in to change notification settings

helbing/input_handle

Repository files navigation

Introduce

input_handle是一个数据过滤库,提供XSS过滤,简单SQL注入过滤和数据类型转换

Usage

简单使用

$handle = new inputHandle();

$data = $handle->inputHandle($data, InputHandle::TYPE_STRING, $defaultVal);

调用函数做额外的处理

inputHandle函数的第四个参数可以添加一些trim,htmlspecialchars等函数对数据做一些额外的处理

$handle = new inputHandle();

$data = $handle->inputHandle($data, InputHandle::TYPE_STRING, $defaultVal, 'trim,htmlspecialchars');

自定义过滤

创建自定义过滤类,并实现Helbing\Handle\Factory接口函数

use Helbing\Handle\Factory;

class MyFilter implements Factory
{
    public function name()
    {
        return 'filter-name';
    }

    public function filter($input)
    {
        return doSomething($input);
    }
}

使用自定义过滤

$handle = new inputHandle();

$handle->push(new MyFilter());

$data = $handle->inputHandle($data, InputHandle::TYPE_STRING);

Require

About

数据过滤库,数据类型处理,SQL注入,XSS过滤等

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages