萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> php編程 >> php常用操作符

php常用操作符

最常見的PHP賦值運算,算術運算符,聯合經營,比較運算符和邏輯運算符。每個類型分別討論如下。

賦值運算符

在PHP基本賦值運算符是“=”。這意味著,左邊的操作數“=”獲取設置為值的右側“=”。

算術運算符

Operator Example Result + 4 + 2 6 - 4 - 2 2 * 4 * 2 8 / 4 / 2 2 % 4 % 2 0 ++ x = 4; x++; x = 5 -- x = 4; x--; x = 3

聯合運營商

你可以結合賦值運算符算術運算符組成一個聯合運營商。聯合運營商如下:

Operator Example Meaning += y += x y = y + x -= y -= x y = y - x *= y *= x y = y * x /= y /= x y = y / x %= y %= x y = y % x

比較運算符

Operator Meaning == is equal to != is not equal to > is greater than >= is greater than or equal to < is less than <= is less than or equal to

邏輯運算符

Operator Meaning || or && and and and or or xor xor ! not
copyright © 萬盛學電腦網 all rights reserved