Javatpoint Logo
Javatpoint Logo

PHP base_convert() Function

PHP base_convert() function is mathematical function. It is used to convert a number from one number base to another.

Syntax:

Parameter Description Required/Optional
number Specify the number to convert. Required
frombase Specify the original base of number. Required
tobase Specify the base to convert to. Required

Example 1

Convert a hexadecimal number to octal number:

Output:

Your number is : a37334
By using 'base_convert()' function your Octal number is :101000110111001100110100

Example 2

Convert a hexadecimal number to octal number:

Output:

Your number is : E196
By using 'base_convert()' function your Octal number is :160626

Example 3

Convert an octal number to a decimal number:

Output:

Your Octal number is : 0031
By using 'base_convert()' function your Decimal number is :25

Example 4

Convert an octal number to a hexadecimal number.

Output:

Your Octal number is : 364
By using 'base_convert()' function your Hexadecimal number is :f4

Example 5

Converting binary to hexadecimal:

Output:

Your binary number is : 110011
By using 'base_convert()' function your hexadecimal number is :33

Next TopicPHP Math





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA