note 101833 modified in function.dechex by danbrown

From: Date: Thu, 13 Jan 2011 15:27:05 +0000
Subject: note 101833 modified in function.dechex by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-175711@lists.php.net to get a copy of this message
After numerous hours of trying to actually receive a hexadecimal digit from dechex, I decided to give it a go myself. I kept trying to do bitwise comparisons on the result however I was comparing strings, <?php function dectohex($dec){ $code='return 0x'.dechex($dec).';'; return eval($code); } ?> This actually returns a hexadecimal value, not a string representation. Hopefully this saves someone else a couple of hours. --was-- After numerous hours of trying to actually receive a hexadecimal digit from dechex, I decided to give it a go myself. I kept trying to do bitwise comparisons on the result however I was comparing strings, function dectohex($dec){ $code='return 0x'.dechex($dec).';'; return eval($code); } This actually returns a hexadecimal value, not a string representation. Hopefully this saves someone else a couple of hours. http://php.net/manual/en/function.dechex.php

« previous php.notes (#175711) next »