1 / 5

PHP Operators

PHP Operators. Lesson 5. Operators. 1. = the assignment operator 2. +, -, *, / you can use parenthesis as grouping symbols to makes your formula more readable Ex. $root=(-$b+ (b*b-4*a*c))/2*a; 3. % modulus operator (returns the remainder when 2 numbers are divided)

thad
Download Presentation

PHP Operators

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PHP Operators Lesson 5

  2. Operators 1. = the assignment operator 2. +, -, *, / you can use parenthesis as grouping symbols to makes your formula more readable Ex. $root=(-$b+ (b*b-4*a*c))/2*a; 3. % modulus operator (returns the remainder when 2 numbers are divided) Ex. $remainder=10%3 (will return 1) 4. . (period) concatenator. This can be combined with = sign Ex. $food = $food . “burger”; is the same as $food .=“burger”;

  3. 5. @ error control operator. This is used so php wont display output. Use them with caution Ex. @quotient = 10/0; This is the error but since there is a @ prefixed in the variable name, therefore the error wont be displayed. Makes findings errors a difficult process. 6. Increment (++) and decrement (--) operators. This is placed either before or after a variable. 7. Prefixing ++$a will increment the value then return the value (which is now incremented) --$a will decrement the value then return the value (which is now decremented)

  4. 8. Postfixing Sa++ will return the value first then increment the value $a– will return the value first then decrement the value 9. Comparison Operators: ==, !=, <, <=, >, >= - returns a Boolean value - i.e. returns either true or false - or returns either 1 or 0 - often used as conditions in conditional statements such as IF-THEN-ELSE, or looping statements 10. Logical operators: and, &&, or, ||, xor, !

  5. Activity <?php //save as prefixandpostfix.php $a = 5; $b = 10; print ++$a; print “<br>”; print $a; print “<br>”; print $b++; print “<br>”; print $b; ?>

More Related