Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the PHP operator and flow control

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

Most people do not understand the knowledge points of this article "PHP operator and process control", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "what is the PHP operator and process control" article.

Operator (1) definition

Operator A symbol that performs an operation on one or more operands (variables or numeric values), so it is also called an operator.

(2) Classification

Assignment operator

Arithmetic operator

Comparison operator

Logical operator

Concatenation operator

Error suppressor

Ternary operator

Self-operation operator

Bit operator

(3) arithmetic operators

(IV) string operator (concatenation operator)

Used in PHP. String concatenation, also known as concatenation operator, is used for string concatenation; in JS, string concatenation is used for +, and for accessing properties in an object.

(5) assignment operator

The right side is assigned to the left side

. =: concatenate the string on the left, and then assign a value to the left

+ =: add the result on the left, and then assign the value to the left

-=: the result on the left minus the result on the right, then assign a value to the left

* =: multiply the result on the left by the result on the right, then assign a value to the left

/ =: cooking on the left, the result on the right, and then assign a value to the left

% =: the one on the left takes the result on the right of the module, and then assigns a value to the left

(VI) comparison operator

Note: PHP specifies that when echo is used to output Boolean types, the echo true output is 1 and the echo false page outputs nothing.

(7) logical operators

& &: logic and, two expressions participate in the operation. If both expressions are true, return true, otherwise return FALSE

| |: logical OR. Two expressions participate in the operation. One returns true if it is true, and FALSE if both are false. |

!: logical non. An expression participates in the operation. True returns FALSE, and false returns TRUE.

(8) precedence of operators

Whoever has the highest priority will be counted first, and the question of which direction to start the calculation is specified.

(IX) other operators

Process Control (1) Sequential execution

Top-down execution is fine, and the default procedure for PHP statement execution is sequential execution, just like PHP.

(2) Branch execution

One-way condition

Two-way condition

Multidirectional condition

If-- unidirectional branch execution if-- bi-directional branch execution if-- multi-directional branch execution

Note a few points with the switch statement:

The statement after case does not need ().

Don't forget to follow each case and jump out of the loop with the break statement.

If the break is not connected to the case, the content is the same as below!

(3) cyclic execution

While statement

Do...while statement

1.while statement

2.do...while cycle

3.for statement

Additional exercise: output the multiplication formula with php

4.break statement

Used for for, while, do...while, foreach, switch to break these statements! After that, a number is used to indicate that there are several layers of loops, and if there is no number by default, it means jumping out of the current loop.

Break statement

5.continute statement

When used in a loop statement, it represents the empty turn of the loop, not the end of the whole loop statement.

Continue statement

6.exit () statement

The purpose is to end the current entire php script, including the die () statement that is often used in awd!

The above is the content of this article on "what is the PHP operator and process control". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report