KEMBAR78
Data types in php | PPTX
DATA TYPES IN PHP1WWW.USTUDY.IN
Data typeA data type refers to the type of data a variable can store. PHP has eight (8) different data typesinteger numbersfloating point numbersstringsBooleansarraysobjectsresourcesnull2WWW.USTUDY.IN
IntegerThe integer data type is used to specify a numeric value without a fractional component. you can declare as given belowinteger $variable; 	$variable =10;3WWW.USTUDY.IN
Real NumberIt 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 4WWW.USTUDY.IN
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.5WWW.USTUDY.IN
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 6WWW.USTUDY.IN
Single quotedThe simplest way to specify a string is to enclose it in single quotes    Example:		   <?php		echo 'this is a simple string';	    ?>WWW.USTUDY.IN7
Double quotedIf the string is enclosed in double-quotes ("),Example:“This is \n a string”, this will evaluate to: This is a string WWW.USTUDY.IN8
Here DocumentsThe 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; 9WWW.USTUDY.IN
NowdocNowdocs 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.10WWW.USTUDY.IN
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.IN11
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. 12WWW.USTUDY.IN
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.IN13
The End14WWW.USTUDY.IN

Data types in php

  • 1.
    DATA TYPES INPHP1WWW.USTUDY.IN
  • 2.
    Data typeA datatype refers to the type of data a variable can store. PHP has eight (8) different data typesinteger numbersfloating point numbersstringsBooleansarraysobjectsresourcesnull2WWW.USTUDY.IN
  • 3.
    IntegerThe integer datatype is used to specify a numeric value without a fractional component. you can declare as given belowinteger $variable; $variable =10;3WWW.USTUDY.IN
  • 4.
    Real NumberIt isalso 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 4WWW.USTUDY.IN
  • 5.
    Boolean Boolean valuesare 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.5WWW.USTUDY.IN
  • 6.
    String String valuesare 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 6WWW.USTUDY.IN
  • 7.
    Single quotedThe simplestway to specify a string is to enclose it in single quotes Example: <?php echo 'this is a simple string'; ?>WWW.USTUDY.IN7
  • 8.
    Double quotedIf thestring is enclosed in double-quotes ("),Example:“This is \n a string”, this will evaluate to: This is a string WWW.USTUDY.IN8
  • 9.
    Here DocumentsThe heredocstring 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; 9WWW.USTUDY.IN
  • 10.
    NowdocNowdocs are tosingle-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.10WWW.USTUDY.IN
  • 11.
    Array An arrayin 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.IN11
  • 12.
    Resource Resources arenot 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. 12WWW.USTUDY.IN
  • 13.
    Null Null isa 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.IN13
  • 14.