PHP Data Types

php-data-types

PHP data types are used to hold different types of data or values, including simple string and numeric types to more difficult data types like objects and arrays.

PHP data types are used to create the variables. PHP supports total eight primitive data types with different functionality. See below the data types:

PHP have 8 kind of different data types. All data types do different kind of works.

Data Types:

a) String

b) Integer

c) Float

d) Boolean

e) Array

f) Objects

g) Resources

h) Null


String: A string is series of characters, where a character is the same as a byte. You can use single or double quotes for print the string.

Example

<?php

$a=”Hello India”;

$b=’Hello World’;

echo $a;

echo “br”;

echo $b;

?>

Result:

Hello India

Hello World


Integer: An Integer is whole number (but without decimals). Integers are subset of real numbers. It is a number between -2,147,483,648 and +2,147,483,647.

Integers:

  • At least one digit (0-9)
  • Cannot contain comma or blanks
  • Integer must not have a decimal point
  • Integer can be either positive or negative

Example

<?php

$a = 500;
var_dump($a);

?>

Result:

int(500)


Coding Tag

Coding Tag always happy to serve you in Information Technology (IT). Learn HTML, CSS, Javascript, PHP, Android, Digital Marketing, Latest IT News and many more.

Leave a Reply

avatar
  Subscribe  
Notify of