Copy code The code is as follows:
/*
* Process Control
*
* 1. Sequential structure
* 2. Branch structure--conditional structure--selection structure
* 1. Single-way branch
* //Condition bool, true or false,> < == !- & || !
* if(condition)
* Execute the following statement
* if(condition)
* {
* code segment;
* code segment;
* }
*
* 2. Two-way branch
* Use else clause
*
* if (condition)
* execute a statement
* else
* Execute a statement
* if (condition){
* One or more codes
* }else{
* One or more codes
* }
*
* 3. Multi-way branches
* You can use if else if and switch case
* //This is a mutually exclusive relationship
* if (condition) {
*
* }else if(condition){
* }else if(condition){
* }else{
* }
* 4. Nested branches
* if(){
* if(){
* }else{
* if(){}
* }
* }
* 3. Loop structure
*
*
*
*
*
* Summary:
* If it is to judge a range, use elseif
* If it is a single match, use switch case
*/
// Single-channel execution
$a=10;
$b=5;
if($a > $b)
echo "$a is greater than $b";
// Dual execution
$a=10;
$b=20;
if($a>$b)
{
echo "$a is greater than $b";
}
else
{
echo "$a is less than $b";
}
//Multiple execution
$hour=date("H ");
if($hour > 6 && $hour < 9)
{
echo "good morning!":
}
else if($hour > 9 && $hour < 12)
{
echo "Good morning";
}
else if($hour > 12 && $hour < 14)
{
echo " Good afternoon";
}
else if($hour > 14 && $hour < 17)
{
echo "Good afternoon";
}
else if($ hour > 17 && $hour < 19)
{
echo "Good evening";
}
else if($hour > 19 && $hour <22)
{
echo "Good evening";
}
else
{
echo "Good evening";
}
//Improve the code based on mutual exclusivity
$hour =date("H");
if($hour < 9)
{
echo "good morning!":
}
else if($hour < 12)
{
echo "Good morning";
}
else if($hour < 14)
{
echo case "Mon":
echo "Monday";
break;"Good afternoon";
}
else if($hour < 17)
{
echo "Good afternoon";
}
else if($ hour > 19)
{
echo "Good evening";
}
else if($hour < 22)
{
echo "Good evening";
}
else
{
echo "Good night";
}
//Judge the day of the week
$week=date("D");//Get the day of the week
switch($week) //switch(variable) variables only use integers and strings
{
case "Mon":
echo "Monday";
break;
case "Tue"
echo "Tuesday";
break;
case "Wed":
echo "Wednesday";
break;
case "Thu":
echo " Thursday";
break;
case "Fri":
echo "Friday";
break;
default:
echo "Weekend";
}
/ /Nested class
$sex=$_GET["sex"];
$age=$_GET["age"];
if($sex=="nan")
{
if($age >= 60)
{
echo "This $sex has retired".($age-60)."years old";
}
else
{
echo "This man is still working, and ".(60-$age)."retired only in 2016";
}
}
else
{
if( $age >= 66)
{
echo "This $sex has retired".($age-66)."years old";
}
else
{
echo "This lady is still working, and".(66-$age)."retired only in 2008";
}
}
?>
http://www.bkjia.com/PHPjc/323560.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323560.htmlTechArticleCopy the code as follows: ?php /* * Process control* * 1. Sequential structure* 2. Branch structure- -Conditional structure--Selection structure* 1. Single-way branch* //Condition bool, true or false, == !- * Code...