PHP Operators

Contact Us or call 1-877-932-8228
PHP Operators

PHP Operators

Operators in PHP are similar to those found in many modern C-like programming languages.

Mathematical Operators
Operator Name Example
+ Addition $a + $b
- Subtraction $a - $b
* Multiplication $a * $b
/ Division $a / $b
% Modulus $a % $b
String Operators
Operator Name Example
. Concatenation
$a . $b
'Hello' . ' world!'
Assignment Operators
Operator Name Example
= Assignment
$a = 1;
$c = 'Hello' . ' world!';
+=
-=
*=
/=
%=
.=
Combination Assignment
$a += 1;
$a -= 1;
$a *= 2;
$a /= 2;
$a %= 2;
$a .= ' world!';
++ Increment By One
$a++;
++$a;
-- Decrement By One
$a--;
--$a;
Other Operators
Operator Name Example
?: Ternary $foo = ($age >= 18) ? 'adult' : 'child';
@ Error Suppression $a = @(1/0);
Next