Summarize the classification and usage of PHP operators. PHP operators are the most commonly used in our programs. I recently read a PHP book to introduce the use of PHP operators. I would like to share them with you here. 1: arithmetic operator: the PHP operator is the most commonly used in our programs. I recently read a PHP book to introduce the use of the PHP operator. let's share it with you.
1: arithmetic operator:
-:-$ A: returns the negative value of.
+: $ A + $ B addition: sum of $ a and $ B.
-: The difference between $ a-$ B subtraction $ a and $ B.
*: The product of $ a * $ B multiplication $ a and $ B.
/: $ A/$ B Division $ a divided by the operator of $ B.
%: $ A % $ B modulo $ a divided by the remainder of $ B.
Note: the division sign ("/") always returns a floating point number, even if the two operations are integers (or integers converted from strings) this is also the case where the modulo $ a % $ B is a negative value.
Example:
- <Html>
- <Head>
- <Title>Php constant definition -- a Tao's essay
Title>
-
Head>
- <Body>
-
Php
- $A=3;
- $B=4;
- $C=5;
- $D=6;
-
- // $D=-$;
- $E= $ A + $ B;
- $F= $ D-$ c;
- $G= $ A * $ d;
- $H= $ D/$;
- Echo "{$ e}<Br>";
- Echo "{$ f}<Br>";
- Echo "{$ g}<Br>";
- Echo "{$ h}<Br>";
- ?>
-
Body>
-
Html>
2: Assignment operator:
The basic assignment operator is "= ". At first, you may think it is "equal", but it is not. It actually means assigning the value of the right expression to the number of left operations.
1): Simple assignment:
- &a="http://www.admin300.com"$b=2008
3): Note that the value assignment operation copies the value of the original variable to the new variable (passing the value assignment), so changing one does not affect the other. This is also suitable for copying values such as large values in a tight loop. PHP 4 supports reference assignment and uses the $ var = & $ othervar; syntax, but this is not possible in PHP 3. "Reference value assignment" means that both variables point to the same data without any data copy. PHP operator skills: the value of the value assignment expression is the value assigned. That is to say, the value of "$ a = 3" is 3. In this way, you can do some tips:
- $a = ($b = 4) + 5;
Bytes. 1: arithmetic operator :...