Copy Code code as follows:
<?php
/* Operational symbol (PHP) operation symbol
*
* By operation symbol function is divided into:
* One, arithmetic operator +-*/% + +-
* Two, string operators. Connection operators
* Third, assignment operator = + = = *=/=%=. =
* Four, comparison operator > < >= <= = = =!= <>!==
* Comparison operator---conditional operator---relational operator
* There is only one result after comparison: Boolean true False
* = = = = = = = = = = = = = = = = = = =
*!== comparison with different content, also requires a different type
* V. Logical operators && OR and | | OR OR! or not
* Logical operators can only manipulate the value of bool, and return the value of bool type
* Six, bitwise operator & | ^ ~ << >> >>>
* Seven, other operators? : ' @ =>->:: & $
* "used to perform operating system kernel
* @ used to block out error messages
* Recommend using "()" to change the priority of an expression
*
*% two purposes: Division operation, Control range, do not use decimal, and do not use negative numbers
*% will be the operator on both sides of the number of integers after the division to the remainder.
*/
To judge a leap year with% symbol
$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 the variable, then increase by 1
+ + $a; $a = $a +1; Start with a 1, in a variable
$a--; $a = $a-1; Start with a variable and then subtract 1 from it.
--$a; $a = $a-1; Subtract 1 from the first, then use the variable
echo $a; Result is 10
+ +--the difference between 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;
The string operator. The use
$name = "Tom";
$age = 27;
$height = 1.75;
echo "My name is: {$name} My age is: {$age} My height is: {$height} m <br>";
Echo ' My name is: '. $name. ' My age is: '. $age. ' My height is: '. $height ' m '. ' <br> ';
echo "\ $age =". $age; $age =27
echo "My name is: {$name} My age is: {$age} My height is: {$height} m <br>; Use of assignment operators
$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 $a;
$str = ' <table> ';
$str. = ' <tr> ';
$str. = ' <td> ';
$str. = ' </td> ';
$str. = ' </tr> ';
$str. = ' </table> ';
echo $str//output a table
Comparison operators
Var_dump (15>6);//return bool (TRUE)
$a = 15;
if (15== $a)
{
echo "A=15";
}
Else
{
echo "A!=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 User name password
$username = "admin";
$password = "123456";
$email = "290080604@qq.com";
if ($username = = "Admin" && $password = "123456")
{
echo "Username password is correct";
}
if ($username = = "" | | $password = = "" | | $email = = "")
{
echo "One cannot be empty";
}
Bitwise operators
$a = 20; 00010100
$b = 30; 00011110
/*
* 20 00010100
* 00011110 &
*-----------------------------------
* 00010100
*
*/
$c = $a & $b;
Echo $c;
/* Supplemental,& | It can also be used as a logical operation
* && and | | The Short circuit problem:
* && in the operation, if the previous number is false, then is true after the entire expression is false, so do not go to the following operand;
* || When an operation is performed, if the previous number is true, the following number is false and the entire expression is true, so the following operand is not executed;
* However,& or | Both sides will be executed when the operation is done.
*/
$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 bit is made up of 8 binary digits (Example 00000000),
A byte is made up of 8 bits, then there are 32 binary digits.
Original code: The highest position in 0 for positive numbers, 1 for negative numbers
+7 00000111
-7 10000111
Inverse code: If a number is positive, its inverse code is the same as the original code;
If a number is negative, then the sign bit is 1, and the rest of you are against the original code;
+7 00000111
-7 11111000
+0 00000000
-0 11111111
Complement: If a number is positive, then its complement and the inverse code is the same as the original code
If a number is negative, its complement = counter code +1, remove the overflow bit of the highest bit
-7 Original Code 10000111 anti-code 11111000
+1
Complement 11111001
The complement of a negative number is known to convert it to decimal.
1. First of all, take the counter
2. Convert it to decimal number
3. Plus minus sign, minus 1.
Example: Complement 11111010
Take the Counter 00000101
4+1=5
-5-1=-6
Bitwise operators:
& Bitwise OR ^ by-bit or ^-bitwise XOR
Example: by position and 01101101
&00110111
00100101
Conclusion: Only 1 1 is 1.
by bit or 01101101
|00110111
01111111
Conclusion: only 0 0 is 0.
Bitwise XOR or 01101101
^00110111
01011010
Conclusion: only 1 0 or 0 1 o'clock is 1. (can also be understood to be in a different state of 1 (true))
Reverse ~00110111 by position
11001000
Conclusion: Change 0 1,1 to 0
Shift Operator:
Move left:<< with symbol right shift:>> unsigned right:>>>
Example: Number x x<<2 x>>2 x>>>2
17 00010001 01000100 00000100 00000100
-17 11101111 10111100 11111011 00111011
Conclusion: positive and negative movement are all 0, minus 0 to left, with symbol right shift complement 1, without sign 0
*/
Use of other operators
$a = 10;
$b = $a >5? $a: 5;//ternary operator, if set up $b= $a otherwise $b=5
Echo $b;
Use ' to execute the operating system shell command
$str = ' Ipconfig/all ';
Echo ' <pre> ';
Echo $str;
Echo ' </pre> ';
?>