msgpack / msgpack-php

msgpack.org[PHP]
BSD 3-Clause "New" or "Revised" License
774 stars 120 forks source link

my code is printed ,but out to show the garbled code, why? #155

Closed richerdyoung closed 3 years ago

richerdyoung commented 3 years ago

the code

       header("Content-type:text/html;charset=utf-8");
        $a = ['id'=>1,'name'=>'tt','sex'=>'men'];
        $msg_a = msgpack_pack($a);
        $a2 = msgpack_unpack($msg_a);
        $msg_b = msgpack_serialize($a);
        $b2 = msgpack_unserialize($msg_b);
        $result = [
            'msg_a'=>$msg_a,
            'a2'=>$a2,
            'msg_b'=>$msg_b,
            'b2'=>$b2,
        ];
        echo "<pre>";
        print_r($result);

thr result

Array
(
    [msg_a] => ��id�name�tt�sex�men
    [a2] => Array
        (
            [id] => 1
            [name] => tt
            [sex] => men
        )

    [msg_b] => ��id�name�tt�sex�men
    [b2] => Array
        (
            [id] => 1
            [name] => tt
            [sex] => men
        )
)

my project can use this , but out to show the garbled code,

EddyLee1010 commented 3 years ago

666

m6w6 commented 3 years ago

msgpack is a binary serialization format, see https://github.com/msgpack/msgpack.