Learn PHP


PHP Number Convert



Convert a hexadecimal number to octal number


            <?php 
                 $hex = "E165";
                 echo base_convert($hex,16,8); 
            ?>
            

output


            160545            

Convert decimal number to binary number


            <?php 
                 echo decbin("3")."<br>";
			     echo decbin("1")."<br>";
			     echo decbin("2018")."<br>";
			     echo decbin("7"); 
            ?>
            

output


            11
1
11111100010
111


Convert decimal to hexadecimal


            <?php 
                    echo dechex("35") . "<br>";
				    echo dechex("12") . "<br>";
				    echo dechex("2018") . "<br>";
				    echo dechex("65"); 
            ?>
            

output


            23
c
7e2
41

Convert decimal to octal


                <?php 
                    echo decoct("30") . "<br>";
				    echo decoct("10") . "<br>";
				    echo decoct("2014") . "<br>";
				    echo decoct("70"); 
                ?>
            

output


                36
12
3736
106

Convert binary to decimal


                <?php 
                    echo bindec("0011") . "<br>";
				    echo bindec("01") . "<br>";
				    echo bindec("11000110011") . "<br>";
				    echo bindec("111"); 
                ?>
            

output


                3
1
1587
7


Convert octal to decimal


                <?php 
                    echo octdec("40") . "<br>";
				    echo octdec("25") . "<br>";
				    echo octdec("2018") . "<br>";
				    echo octdec("65"); 
                ?>
            

output

                32
21
129
53


Convert an octal number to a decimal number


                <?php 
                    $oct = "0031";
    				echo base_convert($oct,8,10); 
                ?>
            

output


                25            

Convert an octal number to a hexadecimal number


                <?php 
                    $oct = "364";
    				echo base_convert($oct,8,16); 
                ?>
            

output


                f4            


Convert hexadecimal to decimal


                <?php 
                    echo hexdec("1e") . "<br>";
				    echo hexdec("a") . "<br>";
				    echo hexdec("11ff") . "<br>";
				    echo hexdec("cceeff");
                ?>
            

output


                30
10
4607
13430527

Convert hexadecimal values to ASCII characters


                <?php 
                    echo hex2bin("48656c");
                ?>
            

output


                Hel            




PHP Tutorials


Home

Introduction

Syntax

Variable

Comment

Echo and Print Statement

Data Types

Boolean

Integer

Number Convert

PHP String

php variable substitution in string

php string element

php string function

php addcslashes function

php addslashes function

php get magic quotes gpc function

php get meta tags function

php urlencode function

PHP $ and $$ Variables

PHP constant

PHP Magic Constants

PHP Static Variable

PHP Super Globals

PHP Globals

PHP Server

PHP reserved variable get

PHP reserved variable post

PHP reserved variable FILES

PHP reserved variable Cookies

PHP reserved variable Session

PHP reserved variable Request

PHP reserved variable environment

PHP Operator

PHP Arithmetic Operator

PHP Comparison Operator

PHP Incrementing and Decrementing Operators

PHP Identical Operators

PHP Logical Operators

PHP String Operators

PHP Ternary Operators

PHP Execution Operators

PHP Operator Precedence

PHP Array Operator

PHP Class

PHP Class Inheritance

PHP constructor and destructor

PHP abstract class

PHP class access control

PHP statement

PHP If statement

PHP else statement

PHP else if statement

PHP control structure statement

PHP while loop

PHP do while loop

PHP for loop

PHP for each loop

PHP break statement

PHP continue statement

PHP declare statement

PHP return statement

PHP require statement

PHP include

PHP require once

PHP include once

PHP goto statement

PHP function

PHP function parameter

PHP function scope

PHP array

PHP array operator

PHP array element loop

PHP array foreach loop

PHP array multidimensional

PHP html forms

PHP get and post method

form redirect

file inclusion

file i/o