Data types in php

11,146 views
11,034 views

Published on

2 Comments
4 Likes
Statistics
Notes
  • thank you
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • kaduvale enakku yaravudhu php teach pannungle.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
11,146
On SlideShare
0
From Embeds
0
Number of Embeds
84
Actions
Shares
0
Downloads
0
Comments
2
Likes
4
Embeds 0
No embeds

No notes for slide

Data types in php

  1. 1. DATA TYPES IN PHP<br />1<br />WWW.USTUDY.IN<br />
  2. 2. Data type<br />A data type refers to the type of data a variable can store. PHP has eight (8) different data types<br />integer numbers<br />floating point numbers<br />strings<br />Booleans<br />arrays<br />objects<br />resources<br />null<br />2<br />WWW.USTUDY.IN<br />
  3. 3. Integer<br />The integer data type is used to specify a numeric value without a fractional component. <br />you can declare as given belowinteger $variable; <br /> $variable =10;<br />3<br />WWW.USTUDY.IN<br />
  4. 4. Real Number<br />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.<br />Some examples of valid floating point numbers include: <br />3.14 <br />0.001 <br />-1.234 <br />0.314E2 // 31.4 <br />1.234E-5 // 0.00001234 <br />-3.45E-3 // -0.00345 <br />4<br />WWW.USTUDY.IN<br />
  5. 5. Boolean <br />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. <br />you can declare as given belowBoolean $variable; where Boolean denotes the type of the variable.<br />5<br />WWW.USTUDY.IN<br />
  6. 6. String <br />String values are sequence of characters, included in a single quote or double quotes, for example, <br />$str1 = "This is a string data type variable";<br />A string literal can be specified in four different ways: <br />single quoted <br />double quoted <br />heredoc syntax <br />nowdoc syntax <br />6<br />WWW.USTUDY.IN<br />
  7. 7. Single quoted<br />The simplest way to specify a string is to enclose it in single quotes <br /> Example:<br /> <?php echo 'this is a simple string'; ?><br />WWW.USTUDY.IN<br />7<br />
  8. 8. Double quoted<br />If the string is enclosed in double-quotes ("),<br />Example:<br />“This is a string”, this will evaluate to: <br />This is a string <br />WWW.USTUDY.IN<br />8<br />
  9. 9. Here Documents<br />The heredoc string structure is a method of including larger strings inside the code. we can use it to include content of any length. <br />To create a heredoc, use a special operator that is made up of three left brackets ( <<< ). The syntax is as follows: <br />$longString = <<< termination_marker any amount of content termination_marker; <br />9<br />WWW.USTUDY.IN<br />
  10. 10. Nowdoc<br />Nowdocs are to single-quoted strings what heredocs are to double-quoted strings. <br />A nowdoc is specified similarly to a heredoc, but no parsing is done inside a nowdoc.<br />10<br />WWW.USTUDY.IN<br />
  11. 11. Array <br />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. <br />WWW.USTUDY.IN<br />11<br />
  12. 12. Resource <br />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. <br />12<br />WWW.USTUDY.IN<br />
  13. 13. Null <br />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. <br />WWW.USTUDY.IN<br />13<br />
  14. 14. The End<br />14<br />WWW.USTUDY.IN<br />

×