PHP杩愮畻绗︿紭鍏堢骇
杩愮畻绗︿紭鍏堢骇
杩愮畻绗︿紭鍏堢骇鎸囧畾浜嗕袱涓〃杈惧紡缁戝畾寰楁湁澶氣滅揣瀵嗏濄備緥濡傦紝琛ㄨ揪寮 1 + 5 * 3 鐨勭粨鏋滄槸 16 鑰屼笉鏄 18 鏄洜涓轰箻鍙凤紙鈥*鈥濓級鐨勪紭鍏堢骇姣斿姞鍙凤紙鈥+鈥濓級楂樸傚繀瑕佹椂鍙互鐢ㄦ嫭鍙锋潵寮哄埗鏀瑰彉浼樺厛绾с備緥濡傦細(1 + 5) * 3 鐨勫间负 18銆傚鏋滆繍绠楃浼樺厛绾х浉鍚岋紝鍒欎娇鐢ㄤ粠宸﹀埌鍙崇殑宸﹁仈椤哄簭銆
涓嬭〃浠庨珮鍒颁綆鍒楀嚭浜嗚繍绠楃鐨勪紭鍏堢骇銆傚悓涓琛屼腑鐨勮繍绠楃鍏锋湁鐩稿悓浼樺厛绾э紝姝ゆ椂瀹冧滑鐨勭粨鍚堟柟鍚戝喅瀹氭眰鍊奸『搴忋
杩愮畻绗︿紭鍏堢骇
缁撳悎鏂瑰悜 | 杩愮畻绗 | 闄勫姞淇℃伅 |
闈炵粨鍚 | clone new | clone 鍜 new |
宸 | [ | array() |
闈炵粨鍚 | ++ -- | 閫掑锛忛掑噺杩愮畻绗 |
闈炵粨鍚 | ~ - (int) (float) (string) (array) (object) (bool) @ | 绫诲瀷 |
闈炵粨鍚 | instanceof | 绫诲瀷 |
鍙崇粨鍚 | ! | 閫昏緫鎿嶄綔绗 |
宸 | * / % | 绠楁湳杩愮畻绗 |
宸 | + - . | 绠楁湳杩愮畻绗﹀拰瀛楃涓茶繍绠楃 |
宸 | << >> | 浣嶈繍绠楃 |
闈炵粨鍚 | < <= > >= <> | 姣旇緝杩愮畻绗 |
闈炵粨鍚 | == != === !== | 姣旇緝杩愮畻绗 |
宸 | & | 浣嶈繍绠楃鍜屽紩鐢 |
宸 | ^ | 浣嶈繍绠楃 |
宸 | | | 浣嶈繍绠楃 |
宸 | && | 閫昏緫杩愮畻绗 |
宸 | || | 閫昏緫杩愮畻绗 |
宸 | ? : | 涓夊厓杩愮畻绗 |
鍙 | = += -= *= /= .= %= &= |= ^= <<= >>= | 璧嬪艰繍绠楃 |
宸 | and | 閫昏緫杩愮畻绗 |
宸 | xor | 閫昏緫杩愮畻绗 |
宸 | or | 閫昏緫杩愮畻绗 |
宸 | , | 澶氬鐢ㄥ埌 |
宸﹁仈琛ㄧず琛ㄨ揪寮忎粠宸﹀悜鍙虫眰鍊硷紝鍙宠仈鐩稿弽銆
Example #1 缁撳悎鏂瑰悜
<?php$a = 3 * 3 % 5; // (3 * 3) % 5 = 4
$a = true ? 0 : true ? 1 : 2; // (true ? 0 : true) ? 1 : 2 = 2
$a = 1;
$b = 2;
$a = $b += 3; // $a = ($b += 3) -> $a = 5, $b = 5
?> 浣跨敤鎷彿鍙互澧炲己浠g爜鐨勫彲璇绘с
Note:
灏界 = 姣斿叾瀹冨ぇ澶氭暟鐨勮繍绠楃鐨勪紭鍏堢骇浣庯紝PHP 浠嶆棫鍏佽绫讳技濡備笅鐨勮〃杈惧紡锛歩f (!$a = foo())锛屽湪姝や緥涓 foo() 鐨勮繑鍥炲艰璧嬬粰浜 $a銆
浠ヤ笂灏辨槸PHP杩愮畻绗︿紭鍏堢骇鐨勮缁嗗唴瀹癸紝鏇村淇℃伅璇峰叧娉∣D浜戝叾瀹冪浉鍏虫枃绔狅紒