• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Php-Continuation
 

Php-Continuation

on

  • 2,534 views

 

Statistics

Views

Total Views
2,534
Views on SlideShare
2,533
Embed Views
1

Actions

Likes
0
Downloads
6
Comments
0

1 Embed 1

http://www.slideshare.net 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Php-Continuation Php-Continuation Presentation Transcript

    • PHP: Hypertext Preprocessor
      The Building Blocks
    • Special Data Types
      Resource - Reference to a third-party resource (a database, for example)
      NULL - An uninitialized variable
      Sample
      <?php
      $testing; // declare without assigning
      print gettype( $testing ); // NULL
      ?>
    • PHP’s Type Functions
      var_dump()- tells you a variable's type and its contents
      Sample
      <php
      $testing = 5;
      var_dump( $testing );
      ?>
    • PHP’s Type Functions
      gettype()function - to acquire the type of any variable. If you place a variable between the parentheses of the function call, gettype() returns a string representing the relevant type (NULL, integer, string, double , boolean)
      Sample
      <?php
      $testing = 5;
      print gettype( $testing ); // integer
      ?>
    • PHP’s Type Functions
      settype()function - to change the type of a variable. To use settype(), you must place the variable to change (and the type to change it to) between the parentheses and separate them by commas
      Sample
      <?php
      $undecided = 3.14;
      settype( $undecided, double );
      print gettype( $undecided );
      print " -- $undecided<br />"; // 3.14
      ?>
    • Operators and Expressions
      Operators- are symbols that enable you to use one or more values to produce a new value. A value that is operated on by an operator is referred to as an operand.
      4+3
       
      Expression- is any combination of functions, values, and operators that resolves to a value.
      4+3=9
      $user=you;
      gettype( $user);
       
      Assignment Operator - takes the value of its right operand and assigns it to its left operand
      $name = "matt";
    • Operators and Expressions
      Arithmetic Operators - The addition operator adds the right operand to the left operand, whereas the subtraction operator subtracts the right operand from the left. The division operator divides the left operand by the right, and the multiplication operator multiplies the left operand by the right. The modulus operator returns the remainder of the left operand divided by the right.
      Example
      (+)Addition (-)Subtraction (/)Division
      (*) Multiplication (%)Modulus
    • Concatenation Operator
      The concatenation operator is a single period (.). Treating both operands as strings, it appends the right operand to the left
      Sample
      "hello"." world" is equivalent to "hello world"
      $centimeters = 212;
      print "the width is ".($centimeters/100)." meters";
    • Combined Assignment Operator
      consists of a standard operator symbol followed by an equals sign.
      Example
      $x = 4;$x = $x + 4; // $x now equals 8
      can instead be written as
      $x = 4;$x += 4; // $x now equals 8
    • Comparison Operators
      perform tests on their operands. They return the boolean value true if the test is successful and return false otherwise. This type of expression is useful in control structures, such as if and while statements
      Example
      $x=5.1
      $x < 5
    • Logical Operators
      To test combinations of booleans
      Sample
      true || false = true
      true && false = false
    • Operator Precedence
      When you use an operator, the PHP engine usually reads your expression from left to right.
      Sample
      4 + 5=9
      4 + 5 * 2 = 18 or 4 + 5 * 2 = 14 or (4 + 5) * 2 = 18
    • Constants
      Variables offer a flexible way of storing data because you can change their values and the type of data they store at any time. If, however, you want to work with a value that you do not want to alter throughout your script's execution, you can define a constant. You must use PHP's built-in function define() to create a constant. After you have done this, the constant cannot be changed. To use the define() function, you must place the name of the constant and the value you want to give it within the call's parentheses. These values must be separated by a comma, like so:
      Example
      define ("CONSTANT_NAME", 42);
      <?php
      define ("USER", "Gerald");
      print "Welcome".USER;
      ?>