dealnews/filter 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dealnews/filter

最新稳定版本:2.0.0

Composer 安装命令:

composer require dealnews/filter

包简介

This class is a drop in replacement and wrapper for filter_var, filter_var_array, filter_input, and filter_input_array. The only filters that are modified are ones using \DealNews\Filter\Filter::FILTER_SANITIZE_STRING.

README 文档

README

Starting with PHP 8.1, the filter type FILTER_SANITIZE_STRING was deprecated. To avoid deprecated errors, this class implements similar behavior as the FILTER_SANITIZE_STRING filter. This is done by changing filters using \DealNews\Filter\Filter::FILTER_SANITIZE_STRING to use FILTER_CALLBACK to a closure implementing behavior similar to what \FILTER_SANITIZE_STRING provides.

This class is a drop in replacement for filter_var, filter_var_array, filter_input, and filter_input_array. The only filter that is is modified are ones using \DealNews\Filter\Filter::FILTER_SANITIZE_STRING.

Example

PHP <= 8.0

This is how you used FILTER_SANITIZE_STRING in PHP <=8.0.

<?php

$input = filter_input_array(
    INPUT_GET,
    [
        'id' => FILTER_VALIDATE_INT,
        'search' => FILTER_SANITIZE_STRING
    ]
);

PHP >=8.1

In PHP 8.1 or higher, you can use DealNews\Filter instead like so.

<?php

use DealNews\Filter\Filter;

$filter = new Filter();

$input = $filter->inputArray(
    INPUT_GET,
    [
        'id' => FILTER_VALIDATE_INT,
        'search' => Filter::FILTER_SANITIZE_STRING
    ]
);

统计信息

  • 总下载量: 2.88k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2024-03-15