Operators

Posted on Updated on

Operators

Operators are utilized to perform operations on variables and values.

PHP separates the operators in the accompanying gatherings:

  • Arithmetic operators
  • Assignment operators
  • Comparison operators
  • Increment/Decrement operators
  • Logical operators
  • String operators
  • Array operators

PHP Arithmetic Operators

The PHP Arithmetic operators are utilized with numeric qualities to perform basic arithmetical operations, for example, expansion, subtraction, augmentation and so forth.

Operator Name Example Result

+ Addition $x + $y Sum of $x and $y

– Subtraction $x – $y Difference of $x and $y

* Multiplication $x * $y Product of $x and $y

/ Division $x/$y Quotient of $x and $y

% Modulus $x % $y Remainder of $x isolated by $y

** Exponentiation $x ** $y Result of raising $x to the $y’th power (Introduced in PHP 5.6)

PHP Assignment Operators

The PHP Assignment operators are utilized with numeric qualities to compose a worth to a variable. The essential task administrator in PHP is “=”. It implies that the left operand gets set to the estimation of the task expression on the privilege.

Assignment Same as… Description

x = y x = y  The left operand gets set to the estimation of the expression on the right

x += y x = x + y  Addition

x – = y x = x – y  Subtraction

x *= y x = x * y  Multiplication

x/= y x = x/y  Division

x %= y x = x % y  Modulus

PHP Comparison Operators

The PHP Comparison operators are utilized to think about two qualities (number or string):

Operator Name Example Result

== Equal $x == $y  Returns genuine if $x is equivalent to $y

=== Identical $x === $y  Returns genuine if $x is equivalent to $y, and they are of the same type

!= Not equal $x != $y  Returns genuine if $x is not equivalent to $y

<> Not equal $x <> $y  Returns genuine if $x is not equivalent to $y

!== Not identical $x !== $y  Returns genuine if $x is not equivalent to $y, or they are not of the same type

> Greater than $x > $y  Returns genuine if $x is more prominent than $y

< Less than $x < $y  Returns genuine if $x is not exactly $y

>= Greater than or meet to $x >= $y Returns genuine if $x is more noteworthy than or equivalent to $y

<= Less than or rise to to $x <= $y  Returns genuine if $x is not exactly or equivalent to $y

PHP Increment/Decrement Operators

The PHP Increment operators are utilized to augment a variable’s quality.

The PHP decrement operators are utilized to decrement a variable’s quality.

Operator Name Description

++$x Pre-increment Increments $x by one, then returns $x

$x++ Post-increment Returns $x, then augmentations $x by one

– $x Pre-decrement Decrements $x by one, then returns $x

$x- – Post-decrement Returns $x, then decrements $x by one

PHP Logical Operators

The PHP logical operators are utilized to join restrictive proclamations.

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 genuine, yet 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 String Operators

PHP has two operators that are uniquely intended for strings.

Operator Name Example Result

. Concatenation $txt1 . $txt2 Concatenation of $txt1 and $txt2

.= Concatenation assignment $txt1 .= $txt2 Appends $txt2 to $txt1

PHP Array Operators

The PHP array operators are utilized to think about exhibits.

Operator Name Example Result

+ Union $x + $y Union of $x and $y

== Equality $x == $y Returns genuine if $x and $y have the same key/esteem pairs

=== Identity $x === $y Returns genuine if $x and $y have the same key/esteem sets in the same request and of the same types

!= Inequality $x != $y Returns genuine if $x is not equivalent to $y

<> Inequality $x <> $y Returns genuine if $x is not equivalent to $y

!== Non-identity $x !== $y Return

For more details and queries please feel free to email, visit or call us. Wishing you the very best for all your future endeavors.

Helpline: 9814666333, 8699444666

Email:info@technocampus.co.in

**************************************************************************************************************

Please fill the FORM and we shall contact you soon.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s