note 107634 modified in function.hex2bin by danbrown

From: Date: Thu, 10 May 2012 20:26:50 +0000
Subject: note 107634 modified in function.hex2bin by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-187807@lists.php.net to get a copy of this message
The function pack("H*" , $hex_string); will not work as expected if $hex_string contains an odd number of hexadecimal digits.

For example:

<?php echo ord(pack("H*", 'F')); ?>

will return 240 not 15. Use pack("H*", '0F'); instead. --was-- The function pack("H*" , $hex_string); will not work as expected if $hex_string contains an odd number of hexadecimal digits. For example: echo ord(pack("H*", 'F')); will return 240 not 15. Use pack("H*", '0F'); instead. http://php.net/manual/en/function.hex2bin.php

« previous php.notes (#187807) next »