PHP base_convert() 함수
예시
16진수를 8진수로 변환:
<?php
$hex = "E196";
echo base_convert($hex,16,8);
?>
정의 및 사용
base_convert() 함수는 숫자를 한 숫자에서 다른 숫자로 변환합니다.
통사론
base_convert(number,frombase,tobase);
매개변수 값
Parameter | Description |
---|---|
number | Required. Specifies the number to convert |
frombase | Required. Specifies the original base of number. Has to be between 2 and 36, inclusive. Digits in numbers with a base higher than 10 will be represented with the letters a-z, with a meaning 10, b meaning 11 and z meaning 35 |
tobase | Required. Specifies the base to convert to. Has to be between 2 and 36, inclusive. Digits in numbers with a base higher than 10 will be represented with the letters a-z, with a meaning 10, b meaning 11 and z meaning 35 |
기술적 세부 사항
반환 값: | 지정된 기수로 변환 된 숫자 |
---|---|
반환 유형: | 끈 |
PHP 버전: | 4+ |
더 많은 예
예시
8진수를 10진수로 변환:
<?php
$oct = "0031";
echo base_convert($oct,8,10);
?>
예시
8진수를 16진수로 변환:
<?php
$oct = "364";
echo base_convert($oct,8,16);
?>
❮ PHP 수학 참조