CopyPastehas never been so tasty!

Declare / Initialize Binary Number in PHP

by anonymous

  • 0
  • 0
  • 0
82 views

Declare / Initialize Binary Number in PHP

 

Binary Numbers:Universally binary numbers in every language are made up of only 0s and 1s.In PHP Binary numbers are also represented by any variable name followed by ‘ $ ’  (Variable name can be anything like $number, $string etc).

 

e.g.

 

$Binary = 1010101;

 

 Declaring Variable in PHP:

 

 To declare the variable of any type in PHP first write “$”, that is keyword of php. Then write variable name and then semicolon. We can give default value on declaration time. Following is the sample code.

 

 PHP Code:

 $Variable = 1230;

$Variable_string =”Hello”;

$Varable_float= 1.234

 

 This is simple code to declare a variable with default value in Php.

 

 Declaration/Initialization of Binary numbers in Php:

 To declare the variable of binary or decimal type in PHP first write “$”, that is keyword of php. Then write variable name and then semicolon. Following is the sample php code. We can give default value on declaration time. But default value can only be in form of 0s or 1s or combinations of both 0s and 1s in case of binary and in case on decimal it can be combination of digits from 0 to 9. Following is the sample code.

 PHP Code:

 <?php

$Binary_Variable = 101010;

Echo “The value in Binary is : $Binary_variable”;

?>

 This is code to declare a binary variable with default value.

 This simple article tells that how we can initialize/declare binary numbers in PHP.

 

 

Add A Comment: