PHP class fifth automatic type conversion and Process Control
Study Summary:
1. Understand what automatic type conversions are
2. Understanding Basic Process Control Statements
3. Example: Implementing a Calendar Table
Automatic type conversion
1) integer-to-string
echo $num. " ABC ";
2) string-to-integer
$str +3;
3) Turn Boolean type
False case 0 "" "0" false array () NULL undefined
4) Forced type conversion
(int) $str (float) $str (string) $str
5) Constants
Define ("HOST", "localhost");
6) operator
① One Dollar
++ --
② two Yuan
= - * / %
= += -= *= /= %=
> >= < <= = = = = = = = =!==
&& | | !
③ Sanyuan
? :
Process Control:
1. Process Control
2. Functions
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. Abort the loop
Break: Direct End
";}}? >//1 2
Continue: End of this cycle
";}}? >//1 2 4 5 6 7 8 9
Tip: Exit means pause the following program
Echo Date ("W");d ate in W for day of the week
Five. Remaining parts
1.do...while
{$score} ";} while ($score >=60);? >
4.99 Multiplication Table
"; }? >
3.PHP Implementation Calendar Table
Calendar table:
1. Two-layer for loop
2. Interlaced color change
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 a 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";? >
http://www.bkjia.com/PHPjc/871184.html www.bkjia.com true http://www.bkjia.com/PHPjc/871184.html techarticle PHP Fifth automatic type conversion and Process Control Learning Summary: 1. Learn about the 2 of automatic type conversions. Understanding basic Process Control Statements 3. Example: Implement automatic type of calendar table ...