pack problem

From: Date: Wed, 13 Feb 2002 15:34:54 +0000
Subject: pack problem
Groups: php.general 
Request: Send a blank email to php-general+get-84589@lists.php.net to get a copy of this message
Hi I am having some problems with the 'pack' function. Some values just doesnt come out right. For instance, 0xa0 turns into x81a0. Here is some code I used for testing. It packs the value, prints it. Then unpacks the value and prints it # This is wrong, but note that unpack gives the correct value! $v = 0xa0; $x = pack ("n", $v); echo $x . "***"; # 33184 (0x0081a0) $y = unpack ("nfoo", $x); echo $y["foo"] . "**"; # 160 (0xa0) # These guys are ok $v = 0x9; $x = pack ("n", $v); echo $x . "***"; # 9 (0x0009) $y = unpack ("nfoo", $x); echo $y["foo"] . "**"; # 9 (0x0009) $v = 0x100; $x = pack ("n", $v); echo $x . "***"; # 256 (0x0100) $y = unpack ("nfoo", $x); echo $y["foo"] . "**"; # 256 (0x0100) Any ideas?

« previous php.general (#84589) next »