PHP-based operators. 1. arithmetic operators: +,-, *, and %. 2. increment/decrease operators: for example, $ a ++, $ a --, ++ $ a, -- $ a. For example :? Php $ a10; $ b5; $ c $ a ++; assign a value first and then auto-increment. $ C $ a, $ a + 1 $ d $ B --;
1. arithmetic operators: +,-, *,/, and %.
2. increment/decrease operators: for example, $ a ++, $ a --, ++ $ a, -- $.
For example:
$ A = 10;
$ B = 5;
$ C = $ a ++;// Assign values first and then auto-increment. $ C = $ a, $ a = $ a + 1
$ D = $ B --;// Assign values first and then subtract them from each other. $ D = $ B, $ B = $ A-1
Echo '$ a ='. $ a. "|". '$ c ='. $ c .'
'; // $ A = 11, $ c = 10
Echo '$ B ='. $ B. "|". '$ d ='. $ d .'
'; // $ B = 4, $ d = 5
?>
$ A = 10;
$ B = 5;
$ C = ++ $;// Auto-increment first and then assign a value. $ A = $ a + 1, $ c = $
$ D = -- $ B;// First subtract and then assign a value. $ B = $ A-1, $ d = $ B
Echo '$ a ='. $ a. "|". '$ c ='. $ c .'
'; // $ A = 11, $ c = 11
Echo '$ B ='. $ B. "|". '$ d ='. $ d .'
'; // $ B = 4, $ d = 4
?>
3. Comparison operator: Reference Document
4. logical operators:
For example:
$ A = 10; $ B = 7;
If ($ a ++> 8 | $ B ++> 7 ){// $ A ++> 8 is true. $ B ++> 7 is not executed.
Echo 'OK! ';
}
Echo 'a = '. $ a.' B = '. $ B;// Output OK, a = 11, B = 7
Change
$ A = 10; $ B = 7;
If ($ a ++> 10&&$ B ++> 7 ){//$ A ++> 8 is false. $ B ++> 7 is not executed.
Echo 'OK! ';
}
Echo 'a = '. $ a.' B = '. $ B;// A = 11, B = 7
Details:And & all represent logic and where are their differences?
Mainly reflected in priority
And priority And <= <&& Or <= <| For example:
$ A = false | true; // & >=> and;Compare false first | true, and then assign a value
$ B = false or true; // | |>=> or;First assign $ B = false and then compare, so the result is false.
Var_dump ($ a, $ B );//Bool (true) bool (false)
Bytes. 2. increment/decrease operators: for example, $ a ++, $ a --, ++ $ a, -- $ a. For example :? Php $ a = 10; $ B = 5; $ c = $ a ++; // assign values first and then auto-increment. $ C = $ a, $ a = $ a + 1 $ d = $ B --;...