承接 bayfrontmedia/php-sanitize 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

bayfrontmedia/php-sanitize

最新稳定版本:v2.1.2

Composer 安装命令:

composer require bayfrontmedia/php-sanitize

包简介

Simple class used to sanitize, filter and cast data.

README 文档

README

Simple class used to sanitize, filter and cast data.

License

This project is open source and available under the MIT License.

Author

Bayfront Media

Requirements

  • PHP ^8.0 (Tested up to 8.4)

Installation

composer require bayfrontmedia/php-sanitize

Usage

cast

Description:

Ensures a given variable will be returned as a specific type. Defaults to "string".

Parameters:

  • $var (mixed)
  • $type = self::CAST_STRING (string): Any CAST_* constant

Valid cast types are available as the following constants:

  • CAST_ARRAY: array
  • CAST_BOOL: bool
  • CAST_FLOAT: float
  • CAST_INT: int
  • CAST_OBJECT: object
  • CAST_STRING: string

Returns:

  • (mixed)

Example:

use Bayfront\Sanitize\Sanitize;

$input = '1.42';

echo Sanitize::cast($input, Sanitize::CAST_FLOAT);

email

Description:

Filters string for valid email characters.

Parameters:

  • $email (string)

Returns:

  • (string)

Example:

use Bayfront\Sanitize\Sanitize;

echo Sanitize::email('email@example.com');

url

Description:

Filters string for valid URL characters.

Parameters:

  • $url (string)

Returns:

  • (string)

Example:

use Bayfront\Sanitize\Sanitize;

echo Sanitize::url('https://www.example.com);

path

Description:

Filters string for valid path syntax, with optional trailing slash.

This method removes any whitespace, spaces, and leading slashes. It will also convert reverse and multiple slashes to one single forward slash.

Parameters:

  • $path (string)
  • $trailing = true (bool): Require trailing slash

Returns:

  • (string)

Example:

use Bayfront\Sanitize\Sanitize;

$path = '/some/ bad//path';

echo Sanitize::path($path);

escape

Description:

Escape strings and arrays. Other data types return their original value.

NOTE: Use caution when escaping entire arrays, as strings should typically only be escaped when outputting to HTML.

See: https://www.php.net/manual/en/mbstring.supported-encodings.php

Parameters:

  • $value (mixed)
  • $encoding = 'UTF-8' (string)

Returns:

  • (mixed)

Example:

use Bayfront\Sanitize\Sanitize;

$html = '<a href="#">Hyperlink</a>';

echo Sanitize::escape($html);

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-07-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固