romeoz / rock-sanitize
PHP 的灵活清洗器。
0.11.1
2015-11-07 05:01 UTC
Requires
- php: >=5.4.0
- romeoz/rock-base: 0.12.*
Requires (Dev)
- phpunit/phpunit: ^4.7.0
README
特性
- 标量变量、数组和对象的清洗
- 自定义规则
- 为 Rock 框架 的独立模块/组件
安装
从命令行
composer require romeoz/rock-sanitize
在 composer.json 中
{ "require": { "romeoz/rock-sanitize": "*" } }
快速开始
use rock\sanitize\Sanitize; Sanitize::removeTags() ->lowercase() ->sanitize('<b>Hello World!</b>'); // output: hello world!
#### 作为数组或对象
use rock\sanitize\Sanitize; $input = [ 'name' => '<b>Tom</b>', 'age' => -22 ]; $attributes = [ 'name' => Sanitize::removeTags(), 'age' => Sanitize::abs() ]; Sanitize::attributes($attributes)->sanitize($input); /* output: [ 'name' => 'Tom', 'age' => 22 ] */ // all attributes: Sanitize::attributes(Sanitize::removeTags())->sanitize($input);
文档
演示
- 安装 Docker 或 askubuntu
docker run --name demo -d -p 8080:80 romeoz/docker-rock-sanitize
- 打开演示 https://:8080/
要求
- PHP 5.4+
许可证
Rock Sanitize 是开源软件,遵循 MIT 许可证。