The Base_convert () function converts numbers between arbitrary binaries.
Grammar
Base_convert (number,frombase,tobase) parameter description
Number required. The original value.
Frombase required. The original binary of the number.
Tobase required. The binary to convert.
*/
$hexadecimal = ' a37334 ';
Echo Base_convert ($hexadecimal, 16,2); Convert to binary output 101000110111001100110100
echo "
";
$number = "123";
Echo Base_convert ($number, 10,2); Convert to binary output 1111011
echo "
";
Echo Base_convert ($number, 10,8); Convert to octal output 173
echo "
";
Echo Base_convert ($number, 10,16); Convert to hexadecimal output 7b
$number 2 = "100000101";
echo "
";
Echo Base_convert ($number 2,2,10); Convert to decimal output 261
echo "
";
Echo Base_convert ($number 2,2,8); Convert to octal output 405
/*
Description
Returns a string that contains the representation of number in the Tobase binary. The binary of number itself is specified by Frombase. Both Frombase and tobase can only be between 2 and 36 (including 2 and 36). Numbers above the decimal are expressed in letters A-Z, for example a means that 10,b represents 11 and Z represents 35.
http://www.bkjia.com/PHPjc/445382.html www.bkjia.com true http://www.bkjia.com/PHPjc/445382.html techarticle the Base_convert () function converts numbers between arbitrary binaries. The syntax Base_convert (number,frombase,tobase) parameter describes number required. The original value. Frombase required. The original binary of the digital ...