PHP base_convert() 函数详解

时间:2020-03-22 17:30:06   收藏:0   阅读:89

定义

base_convert — 将数字进行任意进制之间的转换


用法

base_convert ( string $number , int $frombase , int $tobase ) : string

返回一个字符串,对应 number 以 tobase 进制的表示。number 本身的进制由 frombase 指定。frombase 和 tobase 都只能在 2 和 36 之间(包括 2 和 36)。$number中高于十进制的数字用字母 a-z 表示,例如 a 表示 10,b 表示 11 以及 z 表示 35,且不区分大小写。


示例

<?php
$hexadecimal = ‘A37334‘;
echo base_convert($hexadecimal, 16, 2);
?>

附录

英文单词,来自官网页面

a number on which a system of counting and expressing numbers is built up, for example 10 in the decimal system and 2 in the binary system


评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!