Saturday, November 8, 2014

PHP Data Types


  • Data types of PHP.
    • PHP provides for six data types. Each data type is used to store a different type of data.
    • An integer is  a whole number that can start with positive or nagative sign.
    • A double value consists of a positive and nagative sign,digits, an optional decimal point, and optional decimal digist.
    • A boolean data type is used to represent a boolean value that is either True or False.
    • A string data type contains string that are made up of any characters.
    • An array data type is used to store one or more items called elements.Each element stores a value that you can refer to with an index.
    • An object data type.
  • Declaring variables in PHP.
    • Variable stores a value that can change as the program executes. In php, variables are easy to spot beacause they all begin with dollar sign ($).
    • To declare a variable, code the dollar sign ($) followed by the variable name. Then, to assign a value to  the variable, code assignment operator (=) followed by an expression that return value for the variable.
      • Example: $count=10; or name='nguyen tien dung'.
  • Declaring constants in PHP.
    • Constants like variable except that once they are declared they can't change or undefined.
      • Example:  define('pi',3,14).

No comments:

Post a Comment