clsystems/php-filter
Composer 安装命令:
composer require clsystems/php-filter
包简介
Php Input Filter package
README 文档
README
Installation via Composer
{
"require": {
"clsystems/php-filter": "~1.0"
}
}
Alternatively, from the command line:
composer require clsystems/php-filter
Usage
use CLSystems\Php\Filter; // Syntax Filter::clean($source, $type); // Example $source = '<h1>Hello World!</h1>'; // Return 'Hello World!' $filtered = Filter::clean($source, 'string'); // Source array $source = [ '<h1>Hello World!</h1>', '<h1>Hello VietNam!</h1>', ]; // Return ['Hello World!', 'Hello VietNam!'] $filtered = Filter::clean($source, 'string'); // Multi-type $source = ' <h1>Hello World!</h1> '; // Return 'Hello World!' $filtered = Filter::clean($source, ['string', 'trim']);
Filter types
- int
- uint (unsigned int)
- float
- ufloat (unsigned float)
- boolean
- alphaNum (alpha numeric string)
- base64
- string (no HTML tags)
- url
- slug (url alias without slash)
- path (url alias with slash)
- unset (return NULL value)
- jsonEncode
- jsonDecode
- yesNo (return 'Y' or 'N')
- inputName (regex /[^a-zA-Z0-9_]/)
- unique (array unique)
- basicHtml
Fallback default
if (function_exists($type)) { if (is_array($value)) { $result = array_map($type, $value); } else { $result = $type($value); } } else { $result = $value; }
统计信息
- 总下载量: 64
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-06-15