1--TEST-- 2GMP serialization and unserialization 3--EXTENSIONS-- 4gmp 5--FILE-- 6<?php 7 8var_dump($n = gmp_init(42)); 9var_dump($s = serialize($n)); 10var_dump(unserialize($s)); 11 12$n = gmp_init(13); 13$n->foo = "bar"; 14var_dump($s = serialize($n)); 15var_dump(unserialize($s)); 16 17var_dump(unserialize('C:3:"GMP":15:{s:2:"42";a:0:{}}')); 18 19try { 20 unserialize('C:3:"GMP":0:{}'); 21} catch (Exception $e) { var_dump($e->getMessage()); } 22 23try { 24 unserialize('C:3:"GMP":9:{s:2:"42";}'); 25} catch (Exception $e) { var_dump($e->getMessage()); } 26 27try { 28 unserialize('O:3:"GMP":0:{}'); 29} catch (Exception $e) { var_dump($e->getMessage()); } 30 31try { 32 unserialize('O:3:"GMP":1:{i:0;i:0;}'); 33} catch (Exception $e) { var_dump($e->getMessage()); } 34 35try { 36 unserialize('O:3:"GMP":1:{i:0;s:0:"";}'); 37} catch (Exception $e) { var_dump($e->getMessage()); } 38 39try { 40 unserialize('O:3:"GMP":2:{i:0;s:1:"0";i:1;i:0;}'); 41} catch (Exception $e) { var_dump($e->getMessage()); } 42 43?> 44--EXPECTF-- 45object(GMP)#%d (1) { 46 ["num"]=> 47 string(2) "42" 48} 49string(27) "O:3:"GMP":1:{i:0;s:2:"2a";}" 50object(GMP)#%d (1) { 51 ["num"]=> 52 string(2) "42" 53} 54string(56) "O:3:"GMP":2:{i:0;s:1:"d";i:1;a:1:{s:3:"foo";s:3:"bar";}}" 55object(GMP)#%d (2) { 56 ["foo"]=> 57 string(3) "bar" 58 ["num"]=> 59 string(2) "13" 60} 61object(GMP)#1 (1) { 62 ["num"]=> 63 string(2) "42" 64} 65string(28) "Could not unserialize number" 66string(32) "Could not unserialize properties" 67string(28) "Could not unserialize number" 68string(28) "Could not unserialize number" 69string(28) "Could not unserialize number" 70string(32) "Could not unserialize properties" 71