For more information about the concepts related to operators, see.
For more information about the concepts related to operators, see.
The Code is as follows:
/* Operator number (PHP) operator symbol
*
* By operator number:
* 1. Arithmetic Operators +-*/% + + --
* 2. String operators. Concatenation Operators
* 3. Value assignment operator = + =-= * =/= % =. =
* 4. Comparison operators >======! = <>! =
* Comparison operator --- condition operator --- relational Operator
* There is only one comparison result: boolean true false
* === The comparison requires the same content and type
*! = When compared, the content is not the same and the type is also required.
* 5. logical operators & and | or! Or not
* Logical operators can only operate bool-type values, and return bool-type values.
* 6. bitwise operators & | ^ ~ <>>>>
* 7. Other operators? : ''@ =>->::& $
* ''Is used to execute the operating system kernel.
* @ Used to block error messages
* We recommend that you use "()" to change the expression priority.
*
* % Has two purposes: division operation; control range; do not use decimal places or negative numbers
* % Convert the numbers on both sides of the operator into integers and perform the remainder division.
*/
// Use the % symbol to determine the leap year
$ Year = 2011;
If ($ year % 4 = 0 & % year % 100! = 0) | $ year % 400 = 0)
{
Echo "run nian ";
}
Else
{
Echo "not run nian ";
}
// ++ -- Use of symbols
$ A = 10;
$ A ++; // $ a = $ a + 1; first use a variable and then increase by 1
+ + $ A; // $ a = $ a + 1; first, auto-increment 1.
$ A --; // $ a = $ A-1; use variables first, then subtract 1
-- $ A; // $ a = $ A-1; First Auto minus 1, then variable
Echo $ a; // The result is 10.
// ++ -- Differences in operations
$ A = 10;
$ B = $ a ++; // B = 10, a = 11
$ C = -- $ B; // c = 9, B = 9
$ D = $ c ++ $ c; // d = 20, c = 11
$ E = $ d ----- $ d; // d = 18, e = 2
Echo $ d;
// Use of the string operator.
$ Name = "tom ";
$ Age = 27;
$ Height = 1.75;
Echo "My name is: {$ name} My age is: {$ age} My height is: {$ height} meters
";
Echo 'My name is: '. $ name.' My age is: '. $ age.' My height is: '. $ height. 'mi '.'
';
Echo "\ $ age =". $ age; // $ age = 27
Echo "My name is: {$ name} My age is: {$ age} My height is: {$ height} meters
"; // Use of the value assignment operator
$ A = 10;
$ A + = 10; // $ a = $ a + 10;
$ A-= 10; // $ a = $ A-10;
$ A * = 10 ;//...
$ A/= 10 ;//...
$ A % = 10; // $ a = $ a % 10;
$ A. = "abc"; // $ a = $ a. "abc ";
Echo $;
$ Str ='
';$ Str. ='
';$ Str. ='
'; $ Str. =' | ';$ Str. ='
';$ Str. ='
';
Echo $ str; // output a table
// Comparison operator
Var_dump (15> 6); // return bool (true)
$ A = 15;
If (15 = $)
{
Echo "a = 15 ";
}
Else
{
Echo "! = 15 ";
}
// Use of logical operators
Var_dump (true & true); // true
Var_dump (true & false); // false
Var_dump (true | false); // true
Var_dump (! True); // false
Var_dump (! False); // true
// Determine the user name and password
$ Username = "admin ";
$ Password = "123456 ";
$ Email = "290080604@qq.com ";
If ($ username = "admin" & $ password = "123456 ")
{
Echo "the user name and password are correct ";
}
If ($ username = "" | $ password = "" | $ email = "")
{
Echo "none of them can be blank ";
}
// Bitwise Operator
$ A = 20; // 00010100
$ B = 30; // 00011110
/*
* 20 00010100
* 30 00011110 &
*-----------------------------------
* 00010100
*
*/
$ C = $ a & $ B;
Echo $ c;
/* Supplement, & | it can also be used for logical operations.
* & | Short circuit problem:
* & When performing an operation, if the first number is false, whether the latter is true or not, and the entire expression is false, the subsequent operands are not executed;
* | When performing an operation, if the preceding number is true, whether the following number is false and the entire expression is true, the subsequent operands are not executed;
* However, & or | during operation, both sides are executed.
*/
$ A = 10;
If ($ a> 5 | $ a ++ <100 ){}
Echo $ a; // output 10
$ B = 10;
If ($ B> 5 | $ B ++ <100 ){}
Echo $ B; // output 11
/*
Bit concept: a single bit is composed of eight binary numbers (for example, 00000000 ),
A byte consists of eight digits, so there are 32 binary numbers.
Original code: the highest bit represents a positive number with 0, and 1 represents a negative number.
+ 7 00000111
-7 10000111
Anticode: If a number is positive, its anticode is the same as the original code;
If a number is negative, the symbol bit is 1, and the rest of the code is reversed;
+ 7 00000111
-7 11111000
+ 0 00000000
-0 11111111
Complement: If a number is positive, its complement and reverse code are the same as the original code.
If a number is negative, its complement = anti-code + 1 removes the overflow bit of the highest bit
-7. Original code 10000111: reverse code 11111000
+ 1
Makeup 11111001
If a negative complement is known, convert it to a decimal number.
1. Get the opposite information for you first
2. convert it to a decimal number.
3. Add a negative number and subtract 1.
Example: Code 11111010
Decimal 00000101
4 + 1 = 5
-5-1 =-6
Bitwise OPERATOR:
& Bitwise AND | bitwise OR ^ bitwise OR ~ Bitwise Inversion
Example: bitwise AND 01101101
& 00110111
00100101
Conclusion: only 1 is 1.
By bit or 01101101
| 00110111
01111111
Conclusion: only 0 0 is 0.
By bit or 01101101
^ 00110111
01011010
Conclusion: only 1 0 or 0 1 is 1. (It can also be understood that the status is 1 (true ))
Bitwise inversion ~ 00110111
11001000
Conclusion: Change 0 to 1, 1, and 0.
Shift Operator:
Shift left: <shift right with a symbol:> unsigned shift right: >>>
Example: number x <2 x> 2 x> 2
17 00010001 01000100 00000100 00000100
-17 11101111 10111100 11111011 00111011
Conclusion: If positive numbers are left and right, 0 is added. If negative numbers are left, 0 is added. If positive numbers are left, 1 is shifted to the right, and 0 is not added.
*/
// Use other operators
$ A = 10;
$ B = $ a> 5? $ A: 5; // triplicate operator. If it is set to $ B = $ a, otherwise $ B = 5
Echo $ B;
// Use ''to execute the shell command of the Operating System
$ Str = 'ipconfig/all ';
Echo'
';
echo $str;
echo '
';
?>