PHP base_convert() 函数详解

定义

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);
?>

附录

英文单词,来自官网页面

  • base: n.基数(如十进制的10和二进制的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

  • convert: v.转换,转化
  • arbitrary: adj.任意的;武断的;随心所欲的;
  • digit: n.(从 0 到 9 的任何一个)数字,数位;
  • inclusive: adj.包括所有的,范围广泛的

原文地址:https://www.cnblogs.com/jiaoran/p/12546993.html