gophp | Golang implementation for PHP 's functions | Hashing library
kandi X-RAY | gophp Summary
kandi X-RAY | gophp Summary
Golang implementation for PHP’s functions.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of gophp
gophp Key Features
gophp Examples and Code Snippets
package main
import (
"fmt"
"github.com/techoner/gophp"
)
func main() {
str := `a:1:{s:3:"php";s:24:"世界上最好的语言";}`
// unserialize() in php
out, _ := gophp.Unserialize([]byte(str))
fmt.Println(out) //map[php:世界上最好的语言]
// serialize() in ph
Community Discussions
Trending Discussions on gophp
QUESTION
I have a file with serialized array in PHP. The content of the file locks like this
...ANSWER
Answered 2022-Feb-18 at 01:24Seams that is unserializing
Don't make assumptions about what is and isn't succeeding in your code. Error responses are the only reliable way to know whether a function succeeded. In this case the assumption may hold, but ignoring errors is always a mistake. Invest time in catching errors and at least panic
them - don't instead waste your time ignoring errors and then trying to debug unreliable code.
invalid operation: out["abcd.jp"] (type interface {} does not support indexing)
The package you're using unfortunately doesn't provide any documentation so you have to read the source to understand that gophp.Unserialize
returns (interface{}, error)
. This makes sense; php can serialize any value, so Unserialize
must be able to return any value.
out
is therefore an interface{}
whose underlying value depends on the data. To turn an interface{}
into a particular value requires a type assertion. In this case, we think the underlying data should be map[string]interface{}
. So we need to do a type assertion:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install gophp
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page