Home  >  Article  >  Backend Development  >  PHP Language Basics 03 By ACReaper_PHP Tutorial

PHP Language Basics 03 By ACReaper_PHP Tutorial

WBOY
WBOYOriginal
2016-07-14 10:12:20939browse

03.01 Logical operators

&&, and
||, or
xor
Here I just emphasize that if you use and or or, remember to add parentheses, otherwise you may make an error. As for the reason, I am not very clear. Anyway, try to use && and || directly. These two are also used in C.
03.02 Bitwise Operators
&, |, ^
The bitwise operators in php are also for integers. Unless both operators are strings, one of them that is not an integer will be converted into an integer. If both operators are strings, the length of the calculation will be the shorter one (except for |, the longer one will be the main one) ), in character units (each character is converted into an integer for calculation).
It can be understood that the shorter one is filled with 0 padding, and & is equivalent to multiplication, so when calculating in terms of digits, the shorter one is the main one, because you have to remove the 0 after the calculation.
And | is equivalent to addition operation, so the longer one shall prevail.
03.02.01 Increment of string
Strings (non-numeric values) are incremented in the same way as perl. A circular queue model is used. If the last letter is a text or number, the last character is increased by 1. If it exceeds, return to the starting point, such as ‘z’ + 1 -》》‘a’
03.03 Error suppression operator@
The error suppression operator @ suppresses error messages during the expression evaluation process. More details will be introduced later
03.04 Control Structure
03.04.01
if structure
The first one is the same as C language.
The second one is more:, and endif; as the end
if(expr)
statement list
elseif(expr):
statement list
else:
statement list
endif;
There are also two types of switch structures. The second one has more switches: and endswitch;
switch (expr):
....
endswitch;
Matching in switch in php is performed using ==.
03.05 Loop control structure
This is the same as C language and will not be discussed here.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477208.htmlTechArticle03.01 Logical operators, and ||, or xor Here I only emphasize that if you use and or or, remember to add brackets, otherwise something may go wrong. I’m not sure why. Anyway, try to use it directly...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn