- .Net
- .Net Design Pattern
- .Net Windows Service
- ADO.NET
- Android
- Angular.js
- Architecture
- ASP.NET Ajax
- ASP.NET Core
- ASP.NET Gridview
- ASP.NET MVC
- ASP.NET Web API
- Automation Anywhere
- AWS
- AWS SDK and C#
- AWS SDK and Node.js
- Azure DevOps
- Blockchain
- Bootstrap
- Coded UI
- CSS
- Django
- Environment
- Excel
- Excel Formula
- Firebase
- Flutter and dart
- Git
- HTML
- HTML 5
- IIS
- Java
- JavaScript
- JMeter
- JQuery
- JSON
- Light Switch 2011
- Linux
- Matplotlib
- Microsoft Bot Framework
- Microsoft Azure
- MSWord
- Node.js
- NumPy
- Pandas
- Photoshop
- PHP
- PHP Codeigniter
- PostGreSQL
- Powerpoint
- PowerShell
- Project Management
- Pyautogui
- Python
- React.js
- Seaborn
- Selenium
- Silverlight
- Software Testing
- Sonarqube
- Spacy
- SQL Server
- SSRS
- UiPath
- VBA For Excel
- VBA For Outlook
- WCF
- WPF
- XML
- XSD

Articles → PHP → Operators In PHP

- Arithmetic operators
- Assignment operators
- Incrementing/Decrementing operators
- Comparison operators
- Logical operators

Operator | Name | Description |
---|---|---|

+ | Add | Sum of 2 operand (left operand + right operand) |

- | Subtract | Difference of 2 operands (left operand – right operand) |

* | Multiply | Product of 2 operands (left operand * right operand) |

/ | Division | Quotient of 2 operands (left operand / right operand) |

% | Modulus | Remainder of division when one operand is divided by other |

- Operand | Negation | Opposite of operand |

. | Concatenation | Combine 2 strings into one. |

Operators | How they are used |
---|---|

a = b | a = b |

a += b | a = a + b |

a -= b | a = a + b |

a *= b | a = a * b |

a /= b | a = a / b |

a %= b | a = a % b |

Operators | Description |
---|---|

++x | This operator increments the value of variable by one and then returns it. |

x++ | This operator returns the variable and then increments it by one. |

--y | This operator decrements the value of variable by one and then returns it. |

y-- | This operator returns the variable and then decrements it by one. |

- Value of the variable "$var" is initialized with 4
- In the first echo statement, the value of variable is incremented by one (value becomes 5) and then displays the value
- In the second echo statement the value of variable is displayed first then increments it by one. At the time of display, the value of variable is 5 and after that it has been incremented to 6
- In the third echo statement, the value of variable is first decremented by one and then displays on the screen. After the last operation the value was incremented to 6 and now after the value is decremented the value of variable becomes 5 again. So, the third echo statement also displays the value as 5
- In the last echo statement, the value is first displayed and then decrements. So, the last echo statement also displays 5

Operators | Description |
---|---|

a == b | Checks if value of a is equal to value of b even if data type is different then this expression returns true else returns false. |

a === b | Checks if value of a is equal to value of b and data type of both the operands are same then this expression returns true else false |

a != b Or a <> b | If value of a is not equal to value of b then this expression returns true else false. |

a !== b | If value of a is not equal to value of b or data type of a is not equal to data type of b then this expression returns true else false. |

a > b | If value of a is greater than value of b then this expression returns true else false. |

a < b | If value of a is greater than or equal to value of b then this expression returns true else false. |

a >= b | If value of a is less than or equal to value of b then this expression returns true else false. |

a <= b | This operator decrements the value of variable by one and then returns it. |

Operators | Name | Description |
---|---|---|

x and y / x && y | And | True of both x and y are true |

x or y / x || y | Or | True if either one or both is true |

x xor y | Xor | True if either one is true but not both |

!x | Not | True if x is not true |

Posted By - | Karan Gupta |

Posted On - | Sunday, May 19, 2013 |

Query/Feedback

Your Email Id | ||

Subject | ||

Query/Feedback | ||