當前位置: 首頁>>代碼示例>>PHP>>正文


PHP msgpack_unserialize函數代碼示例

本文整理匯總了PHP中msgpack_unserialize函數的典型用法代碼示例。如果您正苦於以下問題:PHP msgpack_unserialize函數的具體用法?PHP msgpack_unserialize怎麽用?PHP msgpack_unserialize使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了msgpack_unserialize函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: test

function test($type, $variable, $test)
{
    $serialized = msgpack_serialize($variable);
    $unserialized = msgpack_unserialize($serialized);
    var_dump($variable);
    var_dump($unserialized);
}
開發者ID:chenyongze,項目名稱:msgpack-hhvm,代碼行數:7,代碼來源:025.php

示例2: test

function test($type, $variable)
{
    $unserialized = msgpack_unserialize(pack('H*', $variable));
    echo $type, PHP_EOL;
    echo $variable, PHP_EOL;
    var_dump($unserialized);
}
開發者ID:chenyongze,項目名稱:msgpack-hhvm,代碼行數:7,代碼來源:050.php

示例3: test

function test($type, $variable, $test)
{
    $serialized = pack('H*', $variable);
    $unserialized = msgpack_unserialize($serialized);
    echo $type, PHP_EOL;
    echo bin2hex($serialized), PHP_EOL;
    var_dump($unserialized);
}
開發者ID:chenyongze,項目名稱:msgpack-hhvm,代碼行數:8,代碼來源:020.php

示例4: test

function test($type, $variable)
{
    $serialized = msgpack_serialize($variable);
    $unserialized = msgpack_unserialize($serialized);
    echo $type, PHP_EOL;
    echo bin2hex($serialized), PHP_EOL;
    var_dump($unserialized);
    echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
}
開發者ID:chenyongze,項目名稱:msgpack-hhvm,代碼行數:9,代碼來源:006.php

示例5: test

function test($type, $variable, $test)
{
    $serialized = msgpack_serialize($variable);
    $unserialized = msgpack_unserialize($serialized);
    echo $type, PHP_EOL;
    echo bin2hex($serialized), PHP_EOL;
    var_dump($unserialized);
    echo $test || $unserialized === null ? 'OK' : 'FAIL', PHP_EOL;
}
開發者ID:chenyongze,項目名稱:msgpack-hhvm,代碼行數:9,代碼來源:023.php

示例6: unpack

 /**
  */
 public function unpack($data)
 {
     ini_set('track_errors', 1);
     $out = @msgpack_unserialize($data);
     ini_restore('track_errors');
     if (!isset($php_errormsg)) {
         return $out;
     }
     throw new Horde_Pack_Exception('Error when unpacking Msgpack data.');
 }
開發者ID:jubinpatel,項目名稱:horde,代碼行數:12,代碼來源:Msgpackserialize.php

示例7: unserialize

 /**
  * Deserialize msgpack string to PHP value
  *
  * @param  string $serialized
  * @return mixed
  * @throws Exception\RuntimeException on msgpack error
  */
 public function unserialize($serialized)
 {
     if ($serialized === static::$serialized0) {
         return 0;
     }
     ErrorHandler::start();
     $ret = msgpack_unserialize($serialized);
     $err = ErrorHandler::stop();
     if ($ret === 0) {
         throw new Exception\RuntimeException('Unserialization failed', 0, $err);
     }
     return $ret;
 }
開發者ID:idwsdta,項目名稱:INIT-frame,代碼行數:20,代碼來源:MsgPack.php

示例8: test

function test()
{
    $serialized = msgpack_serialize(null);
    $serialized = substr($serialized, 0, -1);
    $length = mt_rand(1, 255);
    for ($i = 0; $i < $length; ++$i) {
        $serialized .= chr(mt_rand(0, 255));
    }
    // if returned null everything is OK
    if (($unserialized = msgpack_unserialize($serialized)) === null) {
        return true;
    }
    // whole data is read?
    if ($serialized !== msgpack_serialize($unserialized)) {
        return true;
    }
    echo bin2hex($serialized), "\n";
    var_dump($unserialized);
    return false;
}
開發者ID:chenyongze,項目名稱:msgpack-hhvm,代碼行數:20,代碼來源:040.php

示例9: __construct

}
class Foo
{
    public $parent;
    public $children;
    public function __construct()
    {
        $this->parent = null;
        $this->children = array();
    }
    public function addChild(Foo $obj)
    {
        $this->children[] = $obj;
        $obj->setParent($this);
    }
    public function setParent(Foo $obj)
    {
        $this->parent = $obj;
    }
}
$obj1 = new Foo();
for ($i = 0; $i < 10; $i++) {
    $obj = new Foo();
    $obj1->addChild($obj);
}
$o = msgpack_unserialize(msgpack_serialize($obj1->children));
foreach ($obj1->children as $k => $v) {
    $obj_v = $v;
    $o_v = $o[$k];
    echo gettype($obj_v), "  ", gettype($o_v), PHP_EOL;
}
開發者ID:chenyongze,項目名稱:msgpack-hhvm,代碼行數:31,代碼來源:033.php

示例10: print_r

<?php

class test
{
}
print_r(msgpack_unserialize(msgpack_serialize(new test())));
開發者ID:chenyongze,項目名稱:msgpack-hhvm,代碼行數:6,代碼來源:issue023.php

示例11: strlen

         $igbinary_size += strlen($pack);
         if ($unpack === $value || is_object($value) && $unpack == $value) {
             $igbinary_status = 'OK';
         }
     }
     //msgpack
     $pack = null;
     $unpack = null;
     $t = new Benchmark_Timer();
     $t->start();
     for ($i = 0; $i < $loop; $i++) {
         $pack = msgpack_serialize($value);
     }
     $t->setMarker('msgpack_serialize');
     for ($i = 0; $i < $loop; $i++) {
         $unpack = msgpack_unserialize($pack);
     }
     $t->stop();
     //$t->display();
     $profiling = $t->getProfiling();
     unset($t);
     $msgpack_pack += $profiling[1]['diff'];
     $msgpack_unpack += $profiling[2]['diff'];
     $msgpack_size += strlen($pack);
     if ($unpack === $value || is_object($value) && $unpack == $value) {
         $msgpack_status = 'OK';
     }
 }
 $serialize_pack /= $retry;
 $serialize_unpack /= $retry;
 $serialize_size /= $retry;
開發者ID:kazuho,項目名稱:msgpack,代碼行數:31,代碼來源:benchmark.php

示例12: StdClass

<?php

class Demo extends ArrayObject
{
}
$obj = new StdClass();
$demo = new Demo();
$demo[] = $obj;
$demo[] = $obj;
$data = array($demo, $obj, $obj);
print_r(msgpack_unserialize(msgpack_serialize($data)));
開發者ID:chenyongze,項目名稱:msgpack-hhvm,代碼行數:11,代碼來源:bug012.php

示例13: msgpack_unserialize

    // truncated
    for ($i = 0; $i < $len - 1; $i++) {
        $v = msgpack_unserialize(substr($str, 0, $i));
        if (is_object($data) || is_array($data)) {
            if ($v !== null && $v !== false && $v != $data) {
                echo "output at {$i}:\n";
                var_dump($v);
            }
        } else {
            if ($v !== null && $v == $data) {
                continue;
            } else {
                if ($v !== null && $v !== $data) {
                    echo "output at {$i}:\n";
                    var_dump($v);
                    echo "vs.\n";
                    var_dump($data);
                }
            }
        }
    }
    // padded
    $str .= "98398afay21_ ";
    $v = msgpack_unserialize($str);
    if ($v !== $data && !(is_object($data) && $v == $data)) {
        echo "padded should get original\n";
        var_dump($v);
        echo "vs.\n";
        var_dump($data);
    }
}
開發者ID:chenyongze,項目名稱:msgpack-hhvm,代碼行數:31,代碼來源:030.php

示例14: decode

 /**
  * 數據解碼。
  * 
  * @param string $data 指定數據對象。
  * @param int $format 指定編碼格式。(默認值: 1 | JSON, 其它可用值: Encoder::MSGPACK, Encoder::XML)
  * @return array|mixed
  * @throws NotImplementedException
  */
 static function decode($data, $format = 1)
 {
     $s = false;
     switch ($format) {
         case self::JSON:
             $s = json_decode($data, true);
             break;
         case self::MSGPACK:
             $s = msgpack_unserialize($data);
             break;
         case self::IGBINARY:
             $s = igbinary_unserialize($data);
             break;
         case self::XML:
             throw new NotImplementedException('尚未實現此接口。', -1);
             break;
     }
     return $s;
 }
開發者ID:heesey,項目名稱:LeePHP-Socket,代碼行數:27,代碼來源:Encoder.php

示例15: array

<?php

$data_array = array();
for ($i = 0; $i < 5000; $i++) {
    $data_array[mcrypt_create_iv(10, MCRYPT_DEV_URANDOM)] = mcrypt_create_iv(10, MCRYPT_DEV_URANDOM);
}
$time_start = microtime(true);
for ($i = 0; $i < 4000; $i++) {
    $s = msgpack_serialize($data_array);
    $array = msgpack_unserialize($s);
    unset($array);
    unset($s);
}
$time_end = microtime(true);
if ($time_end <= $time_start) {
    echo "Strange, {$i} iterations ran in infinite speed: {$time_end} <= {$time_start}", PHP_EOL;
} else {
    $speed = $i / ($time_end - $time_start);
    printf("%d iterations took %f seconds: %d/s (%s)\n", $i, $time_end - $time_start, $speed, $speed > 400 ? "GOOD" : "BAD");
}
開發者ID:chenyongze,項目名稱:msgpack-hhvm,代碼行數:20,代碼來源:035.php


注:本文中的msgpack_unserialize函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。