PHP / PHP Data Types

Any variable has to declare for its data type.

Data types in PHP where
S. No Data type Details
1 String is a sequence of characters. It is declared in double quotes.
Example: $a = "PHP Language!".
2 Integer It is a non decimal number lies between -2,147,483,648 and 2,147,483,647.
3 Float It is a number with a decimal point. Example: $a = 5.12342;
4 Boolean It is used to represent states which are possible. i.e. TRUE or FALSE.
5 Array It is collection of similar data types. I.e It can store multiple values with a single variable name. $colors = array("blue","green","yellow");
6 Object It is a real world thing or Entity which stores data and information on how to process that data. In PHP object is created with “new” keywordand it should be explicitly declared. In PHP a class contains properties and methods.
Example: To create a class Bulb in php to call a function in that class.
7 NULL


Home     Back