We have upgraded our system to latest version of MyBB. We are very sorry for the downtime ! Read More.
Advertise Here | Remove Ads

PHP 5 Operators
  • 0 Vote(s) - 0 Average


PHP PHP 5 Operators
1
Operators are used to perform operations on variables and values.
PHP divides the operators in the following groups:
  • Arithmetic operators
  • Assignment operators
  • Comparison operators
  • Increment/Decrement operators
  • Logical operators
  • String operators
  • Array operators

PHP Arithmetic Operators
+ (Addition) Example : $x + $y Sum of $x and $y
- (Subtraction)  Example : $x - $y Difference of $x and $y
* (Multiplication) Example : $x * $y Product of $x and $y
/ (Division) Example : $x / $y Quotient of $x and $y
% (Modulus)  Example : $x % $y Remainder of $x divided by $y
** (Exponentiation) Example : $x ** $y Result of raising $x to the $y'th power (Introduced in PHP 5.6)


PHP Assignment Operators
x = y The left operand gets set to the value of the expression on the right
x += y (Same as x = x + y)   Addition
x -= y (Same as x = x - y ) Subtraction
x *= y (Same as x = x * y ) Multiplication
x /= y (Same as x = x / y) Division
x %= y (Same as x = x % y) Modulus


PHP Comparison Operators
== (Equal) Example :  $x == $y Returns true if $x is equal to $y
=== (Identical) Example :  $x === $y Returns true if $x is equal to $y, and they are of the same type
!= (Not equal)  Example : $x != $y Returns true if $x is not equal to $y
<> (Not equal) Example : $x <> $y Returns true if $x is not equal to $y
!== (Not identical)  Example : $x !== $y Returns true if $x is not equal to $y, or they are not of the same type
> (Greater than)  Example : $x > $y Returns true if $x is greater than $y
< (Less than) Example : $x < $y Returns true if $x is less than $y
>= (Greater than or equal to)  Example : $x >= $y Returns true if $x is greater than or equal to $y
<= (Less than or equal to)  Example : $x <= $y Returns true if $x is less than or equal to $y


PHP Increment / Decrement Operators
++$x (Pre-increment)  Increments $x by one, then returns $x
$x++ (Post-increment) Returns $x, then increments $x by one
--$x (Pre-decremen)  Decrements $x by one, then returns $x
$x-- (Post-decrement) Returns $x, then decrements $x by one


PHP Logical Operators
and (And)  Example : $x and $y True if both $x and $y are true
or (Or)  Example : $x or $y True if either $x or $y is true
xor (Xor) Example : $x xor $y True if either $x or $y is true, but not both
&& (And)  Example : $x && $y True if both $x and $y are true
|| (Or ) Example : $x || $y True if either $x or $y is true
! (Not)  Example :  !$x True if $x is not true


PHP String Operators
. (Concatenation) Example : $txt1 . $txt2 Concatenation of $txt1 and $txt2
.= (Concatenation assignment)  Example : $txt1 .= $txt2 Appends $txt2 to $txt1


PHP Array Operators
+ (Union) Example : $x + $y Union of $x and $y
== (Equality) Example :  $x == $y Returns true if $x and $y have the same key/value pairs
=== (Identity) Example : $x === $y Returns true if $x and $y have the same key/value pairs in the same order and of the same types
!= (Inequality)  Example : $x != $y Returns true if $x is not equal to $y
<> (Inequality) Example : $x <> $y Returns true if $x is not equal to $y
!== (Non-identity) Example : $x !== $y Returns true if $x is not identical to $y

[Image: FCgKq6Jl.png]



2
Very helpful information for PHP beginners. +rep from me for this and also I have stick your thread Thumbs Up
Keep up the good job.

Reply


3
(10-29-2017, 11:57 AM)NomanProdhan Wrote: Very helpful information for PHP beginners. +rep from me for this and also I have stick your thread Thumbs Up
Keep up the good job.

Thanks @NomanProdhan for the +rep and thread sticky. I will try to share more helpful information with all here Thumbs Up

Reply





Forum Jump:


Users browsing this thread:
1 Guest(s)

Advertise Here | Remove Ads