Convert binary to hexadecimal using PHP

前端 未结 4 1678
鱼传尺愫
鱼传尺愫 2021-01-28 15:06

How do I convert a binary number (i.e. 1111111) to hexadecimal (i.e. 7f) using PHP? I recognize I could do dechex(bindec(\'1111111\'));, h

4条回答
  •  走了就别回头了
    2021-01-28 15:15

    dechex(bindec($binary));
    

    It is the right way, you are putting extra ")"(Closing Parenthesis) in the end...

    Reference: http://php.net/manual/en/function.bin2hex.php

提交回复
热议问题