Study Summary:
1. Understand what automatic type conversions are
2. Understand the basic Process Control statements
3. Example: the implementation of the calendar form
Automatic type conversion
1) Integer Turn string
echo $num. " ABC ";
2) String Rounding type
$str +3;
3) Boolean type
False case 0 "" 0 "false array () NULL undefined
4) Force type conversion
(int) $str
(float) $str
(String) $str
5) constant
Define ("HOST", "localhost");
6) operator
① a Dollar
++ --
② two Yuan
= - * / %
= += -= *= /= %=
> >= < <= = =!= = =!==
&&!
③ Ternary
? :
Process Control:
1. Process Control
2. function
Process Control:
I. Branching structure
If...elseif....else
Switch...case
If the condition is a fixed value, use the switch statement
Two. Cycle control
For
While
Three. Discontinue circulation
Break: Direct End
";
}
}
? >//1 2
Continue: End this cycle
";
}
}
? >//1 2 4 5 6 7 8 9
Tip: Exit says pause the following program
Echo Date ("W");
Date in W indicates day of the week
Five. The remaining part
1.do...while
{$score} ";
} while ($score >=60);
? >
4.99 Multiplication Table
";
}
? >
3.PHP Implementation Calendar Table
Calendar table:
1. Two-layer for loop
2. Alternate color of interlaced
3. Use the IF condition to judge
4.header Head Change Code
";
for ($i =1; $i <= $days;) {
echo "";
For ($j =0 $j <7; $j + +) {
if ($i > $days) {
echo "";
} else{
echo "{$i}";
}
$i + +;
}
echo "";
}
echo "";
? >
Add background color
";
For ($i =1 $i <= $days;) {
$k + +;
if ($k%2==1) {
echo "";
} else{
echo "";
}
For ($j =0 $j <7; $j + +) {
if ($i > $days) {
echo "";
} else{
echo "{$i}";
}
$i + +;
}
echo "";
}
echo "";
? >
Abort Script
2.exit (); Abort script using
3.die ();
";
Die ("Start script abort from here");
echo "2222222";
? >