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

Where is the PHP process control?

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

Share

Shulou(Shulou.com)06/02 Report--

This article focuses on "where is the PHP process control", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "where is the PHP process control?"

PHP process control is mainly if and switch process control.

When you write code, you often need to perform different actions for different judgments. You can use conditional statements in your code to accomplish this task.

In PHP, the following conditional statements are provided:

If statement-executes code when the condition is established

If...else statement-executes one block of code when the condition is established and another block of code when the condition is not

If...else if....else statement-executes a block of code when one of several conditions is true

Switch statement-executes a block of code when one of several conditions is true

PHP-if statement

The if statement is used to execute code only if the specified condition is established.

Grammar.

If (conditional)

{

Code to be executed when the condition is established

}

If the current time is less than 20, the following example outputs "Have a good day!":

Case study

Run

PHP-if...else statement

To execute one block of code when the condition is established and another block of code when the condition is not, use the if....else statement.

Grammar.

If (conditional)

{

Code executed when the condition is established

}

Else

{

Code executed when the condition does not hold

}

If the current time is less than 20, the following example will output "Have a good day!", otherwise output "Have a good night!":

PHP-if...else if....else statement

To execute a block of code when one of several conditions is true, use the if....else if...else statement. .

Grammar.

If (conditional)

{

Code that executes when the if condition is established

}

Else if (conditional)

{

Code that executes when the elseif condition is established

}

Else

{

Code executed when the condition does not hold

}

The following example outputs "Have a good morning!" if the current time is less than 10, and "Have a good day!" if the current time is not less than 10 and less than 20, otherwise "Have a good night!":

At this point, I believe that everyone has a deeper understanding of "PHP process control", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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