PHP Data Types | PHP Examples
×

PHP Data Types

4362

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:

  1. String
  2. Integer
  3. Float
  4. Boolean
  5. Array
  6. Objects
  7. Resources
  8. 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.

PHP 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)


Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments