PHP Operator
PHP Tutorial » PHP Operator
- Arithmetic Operators
- Operator Precedence
- Assignment Operators
- Comparison Operators
- Bitwise Operators
- Error Control Operators
- Execution Operators
- Logical Operators
- Incrementing/Decrementing Operators
- Array Operators
- String Operators
- Type Operators
An operator is something that takes one or more expression and gives another value.
PHP Arithmetic Operators example
PHP arithmetic operators are used with numeric values to perform common arithmetical operations, such as: addition ($a + $b), subtraction ($a - $b), multiplication ($a * $b), division($a / $b), modulus($a % $b), exponentiation($a ** $b).
<!DOCTYPE html>
<html>
<body>
<h1>PHP Arithmetic Operators example</h1>
<?php
</body>
echo (4+8).",\n";
echo (24-6).",\n";
echo (12*3).",\n";
echo (12/3).",\n";
echo (4%8).",\n";
echo (2**6).",\n";
?>
</html>
PHP Assignment Operators, example
Basic PHP assignment operator is "=" (without quotes). Meaning: left operand gets set to the value of the assignment expression on the right.
Example of assignment operatore used in PHP:
1. x = y as: x =y, (x assigned y)
2. x += y as x = x + y, (Addition)
3. x -= y as x = x - y, (Subtraction)
4. x *= y as x = x * y, (Multiplication)
5. x /= y as x = x / y, (Division)
6. x %= y as x = x % y, (Modulus)
<!DOCTYPE html>
<html>
<body>
<h1>PHP Assignment Operators</h1>
<?php
$x = 125;
echo $x.",<br />";$y = 25;
$y += 110;
echo $y.",<br />";$z = 55;
$z -= 32;
echo $z.",<br />";$a = 10;
$b= 6;
echo $a * $b.",<br />";?>
</body>
</html>
PHP Increment / Decrement Operators
The PHP increment operators - used to increment a variable's.
The PHP decrement operators - used to decrement a variable's value.
1. ++$x : Increments $x by one, then returns $x2. $x++ : Returns $x, then increments $x by one
3. --$x : Decrements $x by one, then returns $x
4. $x-- : Returns $x, then decrements $x by one
<!DOCTYPE html>
<html>
<body>
<h1>PHP Increment / Decrement Operators</h1>
<?php
$x = 14;
echo ++$x.",<br />";$y = 22;
echo $y++.",<br />";$z = 12;
echo --$z.",<br />";$w = 11;
</body>
echo $w--.",<br />";
?>
</html>
php operator, precedence, =, or, modulo, not supported for string, overload, and, in variable, double question marq
PHP Operator Types - php tutorial
This tool makes it easy to create, adjust, and experiment with custom colors for the web.

Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.

Find here examples of creative and unique website layouts.

Find here examples of creative and unique website CSS HTML menu.