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

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

内容简介: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...


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

查看所有标签

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

Algorithms of the Intelligent Web

Algorithms of the Intelligent Web

Haralambos Marmanis、Dmitry Babenko / Manning Publications / 2009-7-8 / GBP 28.99

Web 2.0 applications provide a rich user experience, but the parts you can't see are just as important-and impressive. They use powerful techniques to process information intelligently and offer featu......一起来看看 《Algorithms of the Intelligent Web》 这本书的介绍吧!

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具