2. Data type A data type refers to the type of data a variable can store. PHP has eight (8) different data types integer numbers floating point numbers strings Booleans arrays objects resources null 2 WWW.USTUDY.IN
3. Integer The integer data type is used to specify a numeric value without a fractional component. you can declare as given belowinteger $variable; $variable =10; 3 WWW.USTUDY.IN
4. Real Number It is also known as a floating number or floating point number. It is not a whole number and has fractions such as 1.22, 2.45, 100.765 etc. Some examples of valid floating point numbers include: 3.14 0.001 -1.234 0.314E2 // 31.4 1.234E-5 // 0.00001234 -3.45E-3 // -0.00345 4 WWW.USTUDY.IN
5. Boolean Boolean values are true or false, also 0 and empty string evaluates to false, and any numeric value rather than zero, or a string that is not empty evaluates to true. you can declare as given belowBoolean $variable; where Boolean denotes the type of the variable. 5 WWW.USTUDY.IN
6. String String values are sequence of characters, included in a single quote or double quotes, for example, $str1 = "This is a string data type variable"; A string literal can be specified in four different ways: single quoted double quoted heredoc syntax nowdoc syntax 6 WWW.USTUDY.IN
7. Single quoted The simplest way to specify a string is to enclose it in single quotes Example: <?php echo 'this is a simple string'; ?> WWW.USTUDY.IN 7
8. Double quoted If the string is enclosed in double-quotes ("), Example: “This is a string”, this will evaluate to: This is a string WWW.USTUDY.IN 8
9. Here Documents The heredoc string structure is a method of including larger strings inside the code. we can use it to include content of any length. To create a heredoc, use a special operator that is made up of three left brackets ( <<< ). The syntax is as follows: $longString = <<< termination_marker any amount of content termination_marker; 9 WWW.USTUDY.IN
10. Nowdoc Nowdocs are to single-quoted strings what heredocs are to double-quoted strings. A nowdoc is specified similarly to a heredoc, but no parsing is done inside a nowdoc. 10 WWW.USTUDY.IN
11. Array An array in PHP is actually an ordered map. A map is a type that associates values to keys. This type is optimized for several different uses; it can be treated as an array, list (vector), hash table (an implementation of a map), dictionary, collection, stack, queue, and probably more. As array values can be other array s, trees and multidimensional array s are also possible. WWW.USTUDY.IN 11
12. Resource Resources are not an actual data type, but the storing of a reference to functions and resources external to PHP. The most common example of using the resource data type is a database call. 12 WWW.USTUDY.IN
13. Null Null is a special data type which can have only one value, which is itself. Which is to say, null is not only a data type, but also a keyword literal. A variable of data type null is a variable that has no value assigned to it. WWW.USTUDY.IN 13