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'));, however, I am certain that this is not the right way.
I tried bin2hex('1111111') but it resulted in 31313131313131.