freeCodeCamp/guide/english/php/php-operators/index.md

73 lines
1.7 KiB
Markdown
Raw Normal View History

---
title: PHP Operators
---
## PHP Operators
<p>Operators are used to perform operations on variables and values.</p>
<p>PHP divides the operators in the following groups:</p>
<ul>
<li>Arithmetic operators</li>
<li>Assignment operators</li>
<li>Comparison operators</li>
<li>Increment/Decrement operators</li>
<li>Logical operators</li>
<li>String operators</li>
<li>Array operators</li>
</ul>
<h3>PHP Arithmetic Operators</h3>
<p>The PHP arithmetic operators are used with numeric values to perform common arithmetical operations, such as addition, subtraction, multiplication etc.</p>
<table>
<tr>
<th>Operator</th>
<th>Name</th>
<th>Example</th>
<th>Result</th>
</tr>
<tr>
<td>+</td>
<td>Addition</td>
<td>$a + $b</td>
<td>Sum of $a and $b</td>
</tr>
<tr>
<td>-</td>
<td>Subtraction</td>
<td>$a - $b</td>
<td>Difference of $a and $b</td>
</tr>
<tr>
<td>*</td>
<td>Multiplication</td>
<td>$a * $b</td>
<td>Product of $a and $b</td>
</tr>
<tr>
<td>/</td>
<td>Division</td>
<td>$a / $b</td>
<td>Quotient of $a and $b</td>
</tr>
<tr>
<td>%</td>
<td>Modulus</td>
<td>$a % $b</td>
<td>Remainder of $a divided by $b</td>
</tr>
<tr>
<td>**</td>
<td>Exponentiation</td>
<td>$a ** $b</td>
<td>Result of raising $a to the $b'th power </td>
</tr>
</table>
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->