1. Trang chủ
  2. » Mẫu Slide

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

27 194 0

Đ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

Thông tin cơ bản

Định dạng
Số trang 27
Dung lượng 157 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Arithmetic Operators - IIOperator Name Description + Addition Adds the operands - Subtraction Subtracts the second operand from the first operand * Multiplication Multiplies operands wit

Trang 1

PHP Operators

Session 5

Trang 2

 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:

Trang 3

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

Trang 4

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

Trang 5

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

Trang 6

 Use Arithmetic operators

 Use Logical operators

 Use Relational operators

 Use Bitwise operators

 Use Assignment operators

 Use String operators

 Use Increment and Decrement Operators

Trang 7

to perform specific actions

which the operators are evaluated in an expression

Trang 9

Arithmetic Operators - II

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

 Following table lists the different arithmetic operators in PHP:

Trang 10

Relational Operators - I

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

 Following table lists the different relational operators

in PHP

Trang 11

Relational Operators - II

<= Less than or equal to Returns true if the first operand is

less than or equal to the second operand

> 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

Trang 12

String Operators

Concatenation Returns a concatenated string

.= Concatenating assignment Appends the argument on the right

side to the variable

 String operators operate on character data

 Following table lists the different string operators in PHP

Trang 13

Logical Operators

or more test expression in a condition

value

Trang 14

Logical Operators - I

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

operators:

Trang 15

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

Trang 16

Bitwise Operators - I

data

Trang 17

Bitwise Operators - II

Operator Name General Form Description

& AND Operand1 &

Operand2 Sets to 1 if both the bits of both the operands are 1 and 0 otherwise

| OR Operand1 | Operand2 Sets to 1 if either of the bits of the

operands are 1 and 0 otherwise

 Following table lists the different bitwise operators in PHP:

Trang 18

Bitwise Operators - III

Operator Name General Form Description

^ EXCLUSIVE-OR Operand1 ^

Operand2 Compares two bits and sets the bit to 1 if the bits

are different and 0 otherwise

~ COMPLEMENT ~ Operand Compares and sets the bits

that are not set and 0 otherwise

Trang 19

Bitwise Operators - IV

Operator Name General Form Description

<< SHIFT

LEFT Operand1 << Operand2 Shifts the bits of Operand1, Operand2

times to the left

>> SHIFT

RIGHT Operand1 >> Operand2 Shifts the bits of Operand1, Operand2

times to the right

Trang 20

Assignment Operator

side to the value of the expression on the

right side

the relational operator

Trang 21

Increment and Decrement

within loops such as for, do while, and while

Trang 22

Increment and Decrement

Operators - II

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

 Following table lists the different increment and decrement operators in PHP:

Trang 23

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

Trang 25

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:

Trang 26

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

Trang 27

Summary - III

to a variable It enables us to set the operand on the letf side to the value on the right side.

to increase or decrease value of an operand by one

strings into a single string

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

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

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

TÀI LIỆU LIÊN QUAN