Phpunserialize function error, strange?

Source: Internet
Author: User
{Code...} This is code, a simple string, but an error still occurs...
$test_str = "code|s:5:\"ZH9JC\";state|s:10:\"wn4rzbnxpp\";";var_dump(unserialize($test_str));

This is the code, a simple string, but still an error...

Reply content:
$test_str = "code|s:5:\"ZH9JC\";state|s:10:\"wn4rzbnxpp\";";var_dump(unserialize($test_str));

This is the code, a simple string, but still an error...

Is the serialized $ test_str an array? Obviously not after serialize. If yes, serialization does not look like this, as shown below:

$arr = array(            'code' => 'ZH9JC',            'state' => 'wn4rzbnxpp'        );$str = serialize($arr);dump($str);// string(59) "a:2:{s:4:"code";s:5:"ZH9JC";s:5:"state";s:10:"wn4rzbnxpp";}"$content = unserialize($str);dump($content);//array(2) {  ["code"] => string(5) "ZH9JC"  ["state"] => string(10) "wn4rzbnxpp"}

Your string is not a standard serialized value. if the unserialize function cannot identify your character change, it will be wrong.

$ Test_str are the results of serialize?

The format is not serialized...

It is not serialized, so it cannot be converted

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.