1--TEST-- 2unpack() with offset 3--FILE-- 4<?php 5$data = "pad" . pack("ll", 0x01020304, 0x05060708); 6 7$a = unpack("l2", $data, 3); 8printf("0x%08x 0x%08x\n", $a[1], $a[2]); 9 10printf("0x%08x 0x%08x\n", 11 unpack("l", $data, 3)[1], 12 unpack("@4/l", $data, 3)[1]); 13 14try { 15 unpack("l", "foo", 10); 16} catch (ValueError $e) { 17 echo $e->getMessage(), "\n"; 18} 19try { 20 unpack("l", "foo", -1); 21} catch (ValueError $e) { 22 echo $e->getMessage(), "\n"; 23} 24?> 25--EXPECT-- 260x01020304 0x05060708 270x01020304 0x05060708 28unpack(): Argument #3 ($offset) must be contained in argument #2 ($data) 29unpack(): Argument #3 ($offset) must be contained in argument #2 ($data) 30