承接 tysonandre/var_representation_polyfill 相关项目开发

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

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

tysonandre/var_representation_polyfill

最新稳定版本:0.1.3

Composer 安装命令:

composer require tysonandre/var_representation_polyfill

包简介

Polyfill for var_representation: convert a variable to a string in a way that fixes the shortcomings of var_export

README 文档

README

Build Status License Latest Stable Version

var_representation_polyfill is a polyfill for https://pecl.php.net/var_representation

This provides a polyfill for the function var_representation(mixed $value, int $flags = 0): string, which converts a variable to a string in a way that fixes the shortcomings of var_export()

See the var_representation PECL documentation for more details

Installation

composer require tysonandre/var_representation_polyfill

Usage

// uses short arrays, and omits array keys if array_is_list() would be true
php > echo var_representation(['a','b']);
[
  'a',
  'b',
]

// can dump everything on one line.
php > echo var_representation(['a', 'b', 'c'], VAR_REPRESENTATION_SINGLE_LINE);
['a', 'b', 'c']

php > echo var_representation("uses double quotes: \$\"'\\\n");
"uses double quotes: \$\"'\\\n"

// Can disable the escaping of control characters as of polyfill version 0.1.0
// (e.g. if the return value needs to be escaped again)
php > echo var_representation("has\nnewlines", VAR_REPRESENTATION_UNESCAPED);
'has
newlines'
php > echo json_encode("uses single quotes:\0\r\n\$\"'\\");
"uses single quotes:\u0000\r\n$\"'\\"
php > echo json_encode(var_representation("uses single quotes:\0\r\n\$\"'\\",
                                          VAR_REPRESENTATION_UNESCAPED));
"'uses single quotes:\u0000\r\n$\"\\'\\\\'"

统计信息

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

GitHub 信息

  • Stars: 14
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04