Files
freeCodeCamp/guide/english/php/php-operators/index.md
Simon Schindlatz d5adba3e23 Added section for assignment operators. (#24416)
* updated index.md

Added new paragraph for assigment operator. Edited "More Inofrmation" section by adding two links.

* Fixed formatting issues and assignment statement
2018-12-10 18:22:24 -05:00

2.1 KiB

title
title
PHP Operators

PHP Operators

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

The PHP arithmetic operators are used with numeric values to perform common arithmetical operations, such as addition, subtraction, multiplication etc.

Operator Name Example Result
+ Addition $a + $b Sum of $a and $b
- Subtraction $a - $b Difference of $a and $b
* Multiplication $a * $b Product of $a and $b
/ Division $a / $b Quotient of $a and $b
% Modulus $a % $b Remainder of $a divided by $b
** Exponentiation $a ** $b Result of raising $a to the $b'th power

PHP Assignment Operators

The assignment operator is =. The operand on the left side gets assigned the value of the expression on the right.

Example

<?php

  $a = 7; // $a set to 7.
  
 ?>  

More Information: