PHP Basic
PHP HOMEPHP Intro
PHP Install
PHP Syntax
PHP Variables
PHP String
PHP Operators
PHP If...Else
PHP Switch
PHP Arrays
PHP While Loops
PHP For Loops
PHP Functions
PHP Forms
PHP $_GET
PHP $_POST
PHP Advanced
PHP DatePHP Include
PHP File
PHP File Upload
PHP Cookies
PHP Sessions
PHP E-mail
PHP Secure E-mail
PHP Error
PHP Exception
PHP Filter
PHP Database
MySQL IntroductionMySQL Connect
MySQL Create
MySQL Insert
MySQL Select
MySQL Where
MySQL Order By
MySQL Update
MySQL Delete
PHP ODBC
PHP XML
XML Expat ParserXML DOM
XML SimpleXML
PHP and AJAX
AJAX IntroAJAX PHP
AJAX Database
AJAX XML
AJAX Live Search
AJAX RSS Reader
AJAX Poll
PHP Reference
PHP ArrayPHP Calendar
PHP Date
PHP Directory
PHP Error
PHP Filesystem
PHP Filter
PHP FTP
PHP HTTP
PHP Libxml
PHP Mail
PHP Math
PHP Misc
PHP MySQL
PHP SimpleXML
PHP String
PHP XML
PHP Zip
PHP Quiz
PHP QuizPHP Certificate
PHP Operators
| « Previous | Next Chapter » |
Operators are used to operate on values.
PHP Operators
This section lists the different operators used in PHP.
Arithmetic Operators
| Operator | Description | Example | Result |
|---|---|---|---|
| + | Addition | x=2 x+2 |
4 |
| - | Subtraction | x=2 5-x |
3 |
| * | Multiplication | x=4 x*5 |
20 |
| / | Division | 15/5 5/2 |
3 2.5 |
| % | Modulus (division remainder) | 5%2 10%8 10%2 |
1 2 0 |
| ++ | Increment | x=5 x++ |
x=6 |
| -- | Decrement | x=5 x-- |
x=4 |
Assignment Operators
| Operator | Example | Is The Same As |
|---|---|---|
| = | x=y | x=y |
| += | x+=y | x=x+y |
| -= | x-=y | x=x-y |
| *= | x*=y | x=x*y |
| /= | x/=y | x=x/y |
| .= | x.=y | x=x.y |
| %= | x%=y | x=x%y |
Comparison Operators
| Operator | Description | Example |
|---|---|---|
| == | is equal to | 5==8 returns false |
| != | is not equal | 5!=8 returns true |
| <> | is not equal | 5<>8 returns true |
| > | is greater than | 5>8 returns false |
| < | is less than | 5<8 returns true |
| >= | is greater than or equal to | 5>=8 returns false |
| <= | is less than or equal to | 5<=8 returns true |
Logical Operators
| Operator | Description | Example |
|---|---|---|
| && | and | x=6 y=3 (x < 10 && y > 1) returns true |
| || | or | x=6 y=3 (x==5 || y==5) returns false |
| ! | not | x=6 y=3 !(x==y) returns true |
| « Previous | Next Chapter » |
