Slide môn học PHP session 2b PHP operators

27 193 0
Slide môn học PHP session 2b PHP operators

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

PHP Operators Session Review - I   An identifier is use to refer to the memory location with the help of any variable A data type describes the type of data a variable will store The different data types are:  Integer numbers  Floating numbers  Strings  Boolean PHP / Session / Slide of 27 Review - II   Numeric data or text enclosed in the quotes is considered to be a string data type Variable:  Name assigned to a memory location where the data is stored  Enables to retrieve data from the memory location  Dollar sign ‘$’ is placed before a variable name  Variable created without any value assigned to it then that variable takes its value as NULL  Equal to sign ‘=’ is used to assign a value to the varaible PHP / Session / Slide of 27 Review - III    Local variable:  Declared and used inside a function  Lifetime remains till the function terminates Global variable:  Uses its value throughout the page  Declared outside the function  Called in the program with the help of the keyword global Static variable:  Local variable made static with the help of the keyword static  Retains its value even after the function terminates PHP / Session / Slide of 27 Review - IV  Environment variable:  System-defined variable  Provides information about the transactions held between the client and the server  Deals with the action of request and response those are held in between the server and the client PHP / Session / Slide of 27 Objectives        Use Arithmetic operators Use Logical operators Use Relational operators Use Bitwise operators Use Assignment operators Use String operators Use Increment and Decrement Operators PHP / Session / Slide of 27 Operators     Operators are pre-defined symbols that allow to perform specific actions An expression contains operators and operands The operators are assigned precedence values This precedence value indicates the order in which the operators are evaluated in an expression PHP / Session / Slide of 27 Arithmetic Operators - I    Arithmetic Operators are used to perform operations on numbers We use the BODMAS rule to solve precedence between the arithmetic operators Brackets are used to force precedence of operators PHP / Session / Slide of 27 Arithmetic Operators - II Following table lists the different arithmetic operators in PHP:  Operator Name Description + Addition Adds the operands - Subtraction Subtracts the second operand from the first operand * Multiplication Multiplies operands with each other / Division Divides the first operand by the second operand % Modulus Returns the remainder when the first operand is divided by the second operand PHP / Session / Slide of 27 Relational Operators - I  Following table lists the different relational operators in PHP Operator Name Description == Equal to Returns true if both the operands are equal != Not equal to Returns true if the first operand is not equal to the second operand < Less than Returns true if the first operand is less than the second operand PHP / Session / Slide 10 of 27 Logical Operators   Logical operators enable us to combine two or more test expression in a condition Evaluate expressions and return a Boolean value PHP / Session / Slide 13 of 27 Logical Operators - I  PHP provides us with the following logical operators: Operator General Form Description && Expression1&& Expression2 Returns true only if both the expressions are true || Expression1 || Expression2 Returns true if any one of the expression is true ! !Expression Returns true only if the condition is not true PHP / Session / Slide 14 of 27 Logical Operators - II Operator General Form Description AND Expression1 AND Expression2 Returns true only if all the expressions are true OR Expression1 OR Expression2 Returns true if any one of the expression is true XOR Expression1 XOR Expression2 Returns false if both Expression1 and Expression2 are true or if both Expression1 and Expression2 are false and true otherwise PHP / Session / Slide 15 of 27 Bitwise Operators - I   Operate on the bits of an operand Work on small-scale binary representation of data PHP / Session / Slide 16 of 27 Bitwise Operators - II  Following table lists the different bitwise operators in PHP: Operator Name General Form Description & AND Operand1 Operand2 & Sets to if both the bits of both the operands are and otherwise | OR Operand1 | Operand2 Sets to if either of the bits of the operands are and otherwise PHP / Session / Slide 17 of 27 Bitwise Operators - III Operator Name General Form ^ EXCLUSIVE-OR Operand1 Operand2 ~ COMPLEMENT ~ Operand Description ^ Compares two bits and sets the bit to if the bits are different and otherwise Compares and sets the bits that are not set and otherwise PHP / Session / Slide 18 of 27 Bitwise Operators - IV Operator Name General Form Description SHIFT RIGHT Operand1 >> Operand2 Shifts the bits of Operand1, Operand2 times to the right PHP / Session / Slide 19 of 27 Assignment Operator    Enables us to set the operand on the left side to the value of the expression on the right side ‘=’ sign is the assignment operator Different from the equal to ‘= ‘sign used as the relational operator PHP / Session / Slide 20 of 27 Increment and Decrement Operators - I    Increment operators increase the value of the operand by one Decrement operators decrease the value of the operand by one These operators function more effectively within loops such as for, while, and while PHP / Session / Slide 21 of 27 Increment and Decrement Operators - II  Following table lists the different increment and decrement operators in PHP: Operand Operator Name Description ++$a Pre-increment Increments the operand value by one and then returns this new value to the variable $a++ Post-increment Returns the value to the variable and then increments the operand by one PHP / Session / Slide 22 of 27 Increment and Decrement Operators - III Operand Operator Name Description $a Pre- decrement Decrements the operand by one and then returns this new value to the variable $a Post decrement Returns the value to the variable and then decrements the operand by one PHP / Session / Slide 23 of 27 Precedence of Operators  Following table lists illustrates the precedence of operators in PHP Precedence Highest Precedence Operators *, /, % +, - , = && || AND XOR Lowest Precedence OR PHP / Session / Slide 24 of 27 Summary - I    An Operator is any symbol that performs an operation on an operand An operator enables us to work on variables, strings, and numbers Operators enable to control the program flow The types of operators are:  Assignment Operators  Arithmetic operators  String Operators  Logical Operators  Incremental and  Relational Operators Decremental Operators  Bitwise Operators PHP / Session / Slide 25 of 27 Summary - II     Arithmetic operators are used to perform mathematical operations Relational operators compare two operands and determine the relationship between operands Logical operators handle multiple conditions and combines two or more test expression in a condition Bitwise operators operate on the bits of an operand PHP / Session / Slide 26 of 27 Summary - III    Assignment operator allows assigning a value to a variable It enables us to set the operand on the letf side to the value on the right side The increment and decrement operators allows to increase or decrease value of an operand by one The concatenation operator joins two or more strings into a single string PHP / Session / Slide 27 of 27 [...]... Assignment Operators  Arithmetic operators  String Operators  Logical Operators  Incremental and  Relational Operators Decremental Operators  Bitwise Operators PHP / Session 5 / Slide 25 of 27 Summary - II     Arithmetic operators are used to perform mathematical operations Relational operators compare two operands and determine the relationship between operands Logical operators handle multiple... string operators in PHP Operator Name Description Concatenation Returns a concatenated string = Concatenating assignment Appends the argument on the right side to the variable PHP / Session 5 / Slide 12 of 27 Logical Operators   Logical operators enable us to combine two or more test expression in a condition Evaluate expressions and return a Boolean value PHP / Session 5 / Slide 13 of 27 Logical Operators. .. true or if both Expression1 and Expression2 are false and true otherwise PHP / Session 5 / Slide 15 of 27 Bitwise Operators - I   Operate on the bits of an operand Work on small-scale binary representation of data PHP / Session 5 / Slide 16 of 27 Bitwise Operators - II  Following table lists the different bitwise operators in PHP: Operator Name General Form Description & AND Operand1 Operand2 & Sets... precedence of operators in PHP Precedence Highest Precedence Operators *, /, % +, - , = && || AND XOR Lowest Precedence OR PHP / Session 5 / Slide 24 of 27 Summary - I    An Operator is any symbol that performs an operation on an operand An operator enables us to work on variables, strings, and numbers Operators enable to control the program flow The types of operators are:  Assignment Operators. .. operators increase the value of the operand by one Decrement operators decrease the value of the operand by one These operators function more effectively within loops such as for, do while, and while PHP / Session 5 / Slide 21 of 27 Increment and Decrement Operators - II  Following table lists the different increment and decrement operators in PHP: Operand Operator Name Description ++$a Pre-increment... increments the operand by one PHP / Session 5 / Slide 22 of 27 Increment and Decrement Operators - III Operand Operator Name Description $a Pre- decrement Decrements the operand by one and then returns this new value to the variable $a Post decrement Returns the value to the variable and then decrements the operand by one PHP / Session 5 / Slide 23 of 27 Precedence of Operators  Following table lists... the operands are 1 and 0 otherwise PHP / Session 5 / Slide 17 of 27 Bitwise Operators - III Operator Name General Form ^ EXCLUSIVE-OR Operand1 Operand2 ~ COMPLEMENT ~ Operand Description ^ Compares two bits and sets the bit to 1 if the bits are different and 0 otherwise Compares and sets the bits that are not set and 0 otherwise PHP / Session 5 / Slide 18 of 27 Bitwise Operators - IV Operator Name General... Operand2 times to the right PHP / Session 5 / Slide 19 of 27 Assignment Operator    Enables us to set the operand on the left side to the value of the expression on the right side ‘=’ sign is the assignment operator Different from the equal to ‘= ‘sign used as the relational operator PHP / Session 5 / Slide 20 of 27 Increment and Decrement Operators - I    Increment operators increase the value... 27 Logical Operators - I  PHP provides us with the following logical operators: Operator General Form Description && Expression1&& Expression2 Returns true only if both the expressions are true || Expression1 || Expression2 Returns true if any one of the expression is true ! !Expression Returns true only if the condition is not true PHP / Session 5 / Slide 14 of 27 Logical Operators - II Operator General...Relational Operators - II Operator Name Description Greater than Returns true if the first operand is greater than the second operand >= Greater than or equal to Returns true if the first operand is greater than or equal to the second operand PHP / Session 5 / Slide 11 of 27 String Operators   String operators

Ngày đăng: 30/11/2016, 22:11

Từ khóa liên quan

Mục lục

  • PHP Operators

  • Slide 2

  • Review - II

  • Review - III

  • Review - IV

  • Objectives

  • Operators

  • Arithmetic Operators - I

  • Arithmetic Operators - II

  • Relational Operators - I

  • Relational Operators - II

  • String Operators

  • Logical Operators

  • Logical Operators - I

  • Logical Operators - II

  • Bitwise Operators - I

  • Bitwise Operators - II

  • Bitwise Operators - III

  • Bitwise Operators - IV

  • Assignment Operator

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan