定制 cs278/serialization-helpers 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

cs278/serialization-helpers

Composer 安装命令:

composer require cs278/serialization-helpers

包简介

Helpers to work with serialized strings

README 文档

README

Build Status Scrutinizer Code Quality

Helpers for dealing with strings created by the serialize() function in PHP.

Usage

isSerialized($value) — Test if a supplied value is a PHP serialized string, returns true iff the syntax looks correct. This function may produce false negatives because Zend PHP’s unserialize() implementation will work on malformed strings.

isSerialized($value, &$result) — As above but also returns the unserialized value by reference.

unserialize($input) — Converts the serialized input into a PHP data type, returns the resulting data type. If an error occurs during the unserialize operation a SyntaxError will be thrown.

Examples

Test if a value is serialized:

isSerialized($value)

<?php

use Cs278\SerializationHelpers\isSerialized;

isSerialized('b:1');
// bool(false)

isSerialized('d:2.71828');
// bool(true)

Unserialize with error handling:

<?php

use Cs278\SerializationHelpers\unserialize;
use Cs278\SerializationHelpers\Exception\SyntaxError;

try {
    return unserialize('s:"foobar";');
} catch (SyntaxError $e) {
    $logger->warning('Input, `{input}` was not valid serialized data', array(
        'input' => $e->getInput(),
    ));

    return null;
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-01-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固