1. Trang chủ
  2. » Công Nghệ Thông Tin

PHP Developer''''s Dictionary- P19 pdf

5 268 0
Tài liệu đã được kiểm tra trùng lặp

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

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 5
Dung lượng 362,99 KB

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

Nội dung

The == operator compares variable1 to variable2 to see whether they are equal.. === Identical Syntax variable1 === variable2 Description The === operator compares variable1 to variab

Trang 1

The == operator compares variable1 to variable2 to see whether they are equal If they are, true is returned

=== (Identical)

Syntax

variable1 === variable2

Description

The === operator compares variable1 to variable2 to see whether they are

identical and are of the same data type If they are, true is returned

$num1 = 5;

$num2 = 5;

$string = "5";

$result1 = ($num1 === $num2); // returns 1

$result2 = ($num1 === $string); // returns 0

!= (Not Equal)

Syntax

variable1 != variable2

Description

The != operator compares variable1 to variable2 to see whether they are not

equal If they are not equal, true is returned

< (Less Than)

Syntax

variable1 < variable2

Description

Trang 2

> (Greater Than)

Syntax

variable1 > variable2

Description

The > operator checks whether variable1 is greater than variable2 If so, true is

returned

<= (Less Than or Equal)

Syntax

variable1 <= variable2

Description

The <= operator checks whether variable1 is less than or equal to variable2 If

so, true is returned

$num1 = 5;

$num2 = 4;

$result = ($num1 <= $num2); // returns 0

>= (Greater Than or Equal)

Syntax

variable1 >= variable2

Description

The >= operator checks to see if variable1 is greater than or equal to variable2 If

so, true is returned

Incrementing and Decrementing

Trang 3

The incrementing and decrementing operators are used to increase or decrease the values of the items to which they are applied This process can occur in a pre- or post- timeframe, and is most often used to increase or decrease counters, such as in loops

++num (Pre-Increment)

Syntax

++num

Description

The ++ num operator increases the value of num by one If num =0 and ++ num is

applied, num will now equal 1 Because the ++ operator is applied before num , the

increase is applied before anything else For instance, if you tried to print ++ num

when num =0, it would print 1 This is the opposite of post-increment, where 0 would

be printed and the value would be adjusted after the print statement

num (Pre-Decrement)

Syntax

num

Description

The num operator decreases the value of num by one If num =1 and num is

applied, num will now equal 0 Because the operator is applied before num, the decrease is applied before anything else For instance, if you tried to print num when num=1, it would print 0 This is the opposite of post-decrement, where 1 would

be printed and the value would be adjusted after the print statement

num++ (Post-Increment)

Syntax

num++

Description

Trang 4

The num ++ operator increases the value of num by one If num =0 and num ++ is applied, num will now equal 1 Because the ++ operator is applied after num , the

increase is applied after anything else For instance, if you tried to print num++ when

num =0, it would print 0 This is the opposite of pre-increment, where 1 would be printed and the value would be adjusted before the print statement

num (Post-Decrement)

Syntax

num

Description

The num operator decreases the value of num by one If num =1 and num is applied, num will now equal 0 Because the operator is applied after num, the decrease is applied after anything else For instance, if you tried to print num when num =1, it would print 1 This is the opposite of pre-decrement where 0 would

be printed and the value would be adjusted before the print statement

Other

Some groups of operators, such as error control, have only one language element in them For organization reasons, we have included these items in this section of this chapter

@ (Error Control)

Syntax

@expression

Description

The @ operator, which can be prepended to any PHP expression, tells the interpreter

to ignore any error messages that it might encounter

Note

Any errors that are encountered will be stored in the $php_errormsg variable if the track_errors option is set in the configuration file If there

is an error, this enables you to stop the program, access the error, and write it to the page See the die() entry in Chapter 5, "PHP Language Extensions," for more information

Trang 5

` ` (Execution)

Syntax

`command`

Description

The ` ` operator will attempt to execute the shell command If you set a variable

equal to this operator, the results of running command will be stored in the variable

Warning

These are backticks, not single quotes

Logical

Logical operators are very similar to comparison operators and are used to evaluate Boolean expressions When using this type of operator, it is important to understand the corresponding truth tables In this section of the chapter, we discuss these operators and each entry will contain its corresponding truth table

and

Syntax

variable1 and variable2

Description

The and operator evaluates whether both variable1 and variable2 are true, or

equal Table 4.5 contains the truth table for the possible values In understanding the truth table, you can see the only time the equation returns true is when both

variable1 and variable2 are true

Note

The only difference between this operator and the && operator is order

Ngày đăng: 07/07/2014, 05:20

TỪ KHÓA LIÊN QUAN