PHP Data Types
0 4337
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:
- String
- Integer
- Float
- Boolean
- Array
- Objects
- Resources
- 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)
Share:
Comments
Waiting for your comments