Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP base_convert() Function

PHP base_convert() Function

PHP Math Reference Manual PHP Math Reference Manual

Example

Convert a hexadecimal number to an octal number:

Run Example »


Definition and Usage

The base_convert() function converts numbers between arbitrary bases.


Syntax

base_convert(

number,frombase,tobase

);

Parameters Description
number Required. Specifies the number to convert.
frombase Required. Specifies the original base of the number, between 2 and 36 (inclusive). Digits above decimal are represented by the letters a-z, for example a means 10, b means 11, and z means 35.
tobase Required. Specifies the base to convert to, between 2 and 36 (inclusive). Digits above decimal are represented by the letters a-z, for example a means 10, b means 11, and z means 35.

Technical Details

Return Value: number Converted to the specified base.
Return Type: String
PHP Version: 4+

More examples

Example 1

Convert an octal number to a decimal number:

Run Example »

Example 2

Convert an octal number to a hexadecimal number:

Run Example »


PHP Math Reference Manual PHP Math Reference Manual