PHP Basic
PHP HOME
PHP Intro
PHP Install
PHP Syntax
PHP Variables
PHP String
PHP Operators
PHP If...Else
PHP Switch
PHP Arrays
PHP Looping
PHP Functions
PHP Forms
PHP $_GET
PHP $_POST
PHP Advanced
PHP Date
PHP 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 Introduction
MySQL Connect
MySQL Create
MySQL Insert
MySQL Select
MySQL Where
MySQL Order By
MySQL Update
MySQL Delete
PHP ODBC
PHP XML
XML Expat Parser
XML DOM
XML SimpleXML
PHP and AJAX
AJAX Introduction
XMLHttpRequest
AJAX Suggest
AJAX XML
AJAX Database
AJAX responseXML
AJAX Live Search
AJAX RSS Reader
AJAX Poll
PHP Reference
PHP Array
PHP 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 Quiz
Selected Reading
Web Statistics
Web Glossary
Web Hosting
Web Quality
W3Schools Tutorials
W3Schools Forum
Helping W3Schools
|
PHP Operators
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 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 |
 |

|
|
See why there are 20,000+ Ektron integrations worldwide.
Request an INSTANT DEMO or download a FREE TRIAL today. |
|
|
|
|
Jump to: Top of Page
or HOME or
Printer friendly page
W3Schools provides material for training only. We do not warrant the correctness of its contents.
The risk from using it lies entirely with the user.
While using this site, you agree to have read and accepted our
terms of use and
privacy policy.
Copyright 1999-2009 by Refsnes Data. All Rights Reserved.
|
|
|