කොහොමද යාලුවනේ දැ ඔයාලගෙ PHP විචල්ය ගැන දැනුම එහෙම? කලින් පාඩමෙන් කිව්වා වගේ අද මම ඔයාලට PHP Operators ගැන කියල දෙන්නයි හදන්නෙ.
අපිට පරිගණක භාෂා භාවිතා කරනකොට විවිධ වටිනාකම් (Values), තර්ක (logics) සමග වැඩ කරන්න වෙනවා. එවත් සමග වැඩ කරන විට මෙ කියන Operators කියන දේවල් ගොඩාක් ප්රයෝජනවත් වෙනවා.
Operators වර්ග කීපයක් තියෙනවා.
අපිට පරිගණක භාෂා භාවිතා කරනකොට විවිධ වටිනාකම් (Values), තර්ක (logics) සමග වැඩ කරන්න වෙනවා. එවත් සමග වැඩ කරන විට මෙ කියන Operators කියන දේවල් ගොඩාක් ප්රයෝජනවත් වෙනවා.
Operators වර්ග කීපයක් තියෙනවා.
- Arithmetic Operators
- Assignment Operators
- Logical Operators
තමයි ඒ Operators.
මහත දක්වා ඇති පරිදි ඔයාලට එම Operators හදුනාගෙන අධ්යනය කරන්න පුලුවන්.
Arithmetic Operators
| Operator | Description | Example | Result |
|---|---|---|---|
| + | Addition | x=5 x+5 | 10 |
| - | Subtraction | x=6 9-x | 3 |
| * | Multiplication | x=11 x*3 | 33 |
| / | Division | 40/10 13/2 | 4 6.5 |
| % | Modulus (division remainder) | 9%2 22%6 30%2 | 1 4 0 |
| ++ | Increment | x=2 x++ | x=3 |
| -- | Decrement | x=6 x-- | x=5 |
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 | 9==2 returns false |
| != | is not equal | 9!=2 returns true |
| <> | is not equal | 9<>2 returns true |
| > | is greater than | 10>3 returns true |
| < | is less than | 10<3 returns false |
| >= | is greater than or equal to | 6>=7 returns false |
| <= | is less than or equal to | 1<=5 returns true |
Logical Operators
| Operator | Description | Example |
|---|---|---|
| && | and | x=8 y=4 (x < 9 && y > 6) returns false |
| || | or | x=8 y=4 (x==8 || y==5) returns true |
| ! | not | x=8 y=4 !(x==y) returns true |
ඉතින් යාලුවනේ ඔයාලට අද පාඩමෙන් ගැටළු අවොත් කියන්න.මම හත්වෙනි පාඩමෙන් මෙම Operators වලට උදාහරණ කීපයක් දෙන්නම්.එතෙක් අයුබෝවන්....!
ෆට්ට....
ReplyDelete