recycledbeans/is-base64 问题修复 & 功能扩展

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

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

recycledbeans/is-base64

最新稳定版本:v1.0.6

Composer 安装命令:

composer require recycledbeans/is-base64

包简介

Adds a quick and easy method for determining whether a string is base64-encoded.

README 文档

README

From time to time, I've found it necessary to validate whether a bit of text is already encoded in base64. Since PHP does not include an easy function to do this, I decided to write this. This package does one simple thing: it adds some nice helper functions to know whether a text string is base64-encoded or not.

Installation

You can easily install with composer:

composer require recycledbeans/is-base64

Usage

is_base64()

<?php 

$is_b64 = is_base64('I am not base64-encoded'); // returns false

$is_b64 = is_base64('SSBhbSBiYXNlNjQtZW5jb2RlZAo='); // returns true

is_base64_encode()

Useful when you do not want to have to check whether something is encoded before encoding. Will ensure that the string is base64-encoded and encode it if the string was not previously.

$my_encoded_string = is_base64_encode($_REQUEST['could_be_base64_encoded_or_not']); // returns base64-encoded string

is_base64_decode()

Useful when you do not want to have to check whether something is encoded before decoding. Will return the string value whether the original string was already base64-encoded or not.

$my_encoded_string = is_base64_decode($_REQUEST['could_be_base64_encoded_or_not']); // returns decoded string

Examples

$my_encoded_string = $_REQUEST['should_be_encoded'];

if (! is_base64($my_encoded_string)) {

    $my_encoded_string = base64_encode($my_encoded_string);

}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-06-13