Internet Technology

Unit Five: XML, DTD, XSTL, XHTML

place your ad here

Operators in PHP || Server Side Scripting || OnlineNotesNepal

Operators in PHP || Server Side Scripting || OnlineNotesNepal

Operators in PHP

Operators in PHP are symbols that tell the PHP processor to perform certain actions.

PHP Arithmetic Operators

The arithmetic operators are used to perform common arithmetical operations,

PHP Arithmetic Operator

PHP Assignment Operators

The assignment operators are used to assign values to variables.

PHP Assignment Operator

PHP Comparison Operators

The comparison operators are used to compare two values in a Boolean fashion.

Operator

Name

Example

Result

==

Equal

$x == $y

True if $x is equal to $y

===

Identical

$x === $y

True if $x is equal to $y, and they are of the same type

!=

Not equal

$x != $y

True if $x is not equal to $y

<>

Not equal

$x <> $y

True if $x is not equal to $y

!==

Not identical

$x !== $y

True if $x is not equal to $y, or they are not of the same type

<

Less than

$x < $y

True if $x is less than $y

>

Greater than

$x > $y

True if $x is greater than $y

>=

Greater than or equal to

$x >= $y

True if $x is greater than or equal to $y

<=

Less than or equal to

$x <= $y

True if $x is less than or equal to $y

PHP Comparison Operator

PHP Incrementing and Decrementing Operators

The increment/decrement operators are used to increment/decrement a variable’s value.

Operator

Name

Effect

++$x

Pre-increment

Increments $x by one, then returns $x

$x++

Post-increment

Returns $x, then increments $x by one

–$x

Pre-decrement

Decrements $x by one, then returns $x

$x–

Post-decrement

Returns $x, then decrements $x by one

PHP Increment and Decrement Operator

PHP Logical Operators

The logical operators are typically used to combine conditional statements.

Operator

Name

Example

Result

And

And

$x and $y

True if both $x and $y are true

Or

Or

$x or $y

True if either $x or $y is true

Xor

Xor

$x xor $y

True if either $x or $y is true, but not both

&&

And

$x && $y

True if both $x and $y are true

||

Or

$x || $y

True if either $x or $y is true

!

Not

!$x

True if $x is not true

PHP Logical Operator

PHP String Operators

There are two operators which are specifically designed for strings.

Operator

Description

Example

Result

.

Concatenation

$str1 . $str2

Concatenation of $str1 and $str2

.=

Concatenation assignment

$str1 .= $str2

Appends the $str2 to the $str1

PHP String Operator

If you liked our content Operators in PHP, then you will also like

Please don’t forget to connect with us through our social media sites. Facebook: Online Notes Nepal, Instagram: @online_notes_nepal, LinkedIn: @onlinenotesnepal, and Twitter:@onlinenotenepal.

advertise here
webtrickshome