banner image

What is Datatype ?
  • A computer does not know the difference between "1234" and "abcd." A datatype is a classification that dictates what a variable or object can hold in computer programming known as Datatype.
Types of Datatypes
1. Integer
2. Long
3. Short
4. String
5. Void
6. Boolean
7. Date
8.  Double
9.  Floating -point Number

An integer is a datatype that hold non-decimal number between -2,147,483,648 and 2,147,483,647. An integer must have at least one digit.
An integer must not have a decimal point. 
Size of an Integer is an 4 bytes (32 bits).

example :  $x=1234;

2. Long
The size of the long datatype is 8 bytes (64 bits). The minimum value is -9 223 372 036 854 775 808, the maximum value is 9 223 372 036 854 775 807.

3. Short
The size of the short type is 2 bytes (16 bits) and, accordingly, it allows expressing the range of values equal to 2 to the power 16: 2^16 = 65 536.Since the short type is a signed one, and contains both positive and negative values, the range of values is between -32 768 and 32 767.

4. Strings
A strings is series of characters, where a character is the same as a byte. This means that PHP only supports a 256-character set.

4. Char
The char type takes 1 byte of memory (8 bits) and allows expressing in the binary notation 2^8=256 values. The char type can contain both positive and negative values. The range of values is from -128 to 127.

5. Void
This type is used either to indicate that the function does not return any value, or as a function parameter it denotes the absence of parameters. 

6. Boolean
This is the simplest type. A boolean expresses a truth value. It can be either TRUE or FALSE

7.  Date  
date(format, timestamp)
example :  $today = date("d/m/Y");
8. Double
There is no difference in PHP. float , double or real are the same datatype
9. Float
Is the numbers with decimal points , like 3.14.
size of float is the 64 bit IEEE format
  10.  Enum
Data of the enum type belong to a certain limited set of data. Defining the enumeration type:
Example :
enum months  // enumeration of named constants

11. Null
The predefined constant variable NULL is of the void type. It can be assigned to variables of any other fundamental types without conversion. The comparison of fundamental type variables with the NULL value is allowed.

If the string is not initiated, then assign our predfined value to it 
if(some_string == NULL ) 

Reviewed by Admin on May 02, 2020 Rating: 5

No comments:

Powered by Blogger.