golang实现php里的serialize()和unserialize()序列和反序列方法

栏目: PHP · 发布时间: 5年前

内容简介:github地址:

Golang 实现 PHP 里的 serialize() 、 unserialize()

安装

go get -u github.com/techleeone/gophp/serialize

用法

package main

import (
    "fmt"

    "github.com/techleeone/gophp/serialize"
)

func main() {

    str := `a:1:{s:3:"php";s:24:"世界上最好的语言";}`

    // unserialize() in php
    out, _ := serialize.UnMarshal([]byte(str))

    fmt.Println(out) //map[php:世界上最好的语言]

    // serialize() in php
    jsonbyte, _ := serialize.Marshal(out)

    fmt.Println(string(jsonbyte)) // a:1:{s:3:"php";s:24:"世界上最好的语言";}

}

github地址: https://github.com/techleeone...


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Introduction to Algorithms, 3rd Edition

Introduction to Algorithms, 3rd Edition

Thomas H. Cormen、Charles E. Leiserson、Ronald L. Rivest、Clifford Stein / The MIT Press / 2009-7-31 / USD 94.00

Some books on algorithms are rigorous but incomplete; others cover masses of material but lack rigor. Introduction to Algorithms uniquely combines rigor and comprehensiveness. The book covers a broad ......一起来看看 《Introduction to Algorithms, 3rd Edition》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

MD5 加密
MD5 加密

MD5 加密工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具