PHP basic syntax and data type:
(1), PHP basic syntax:
1, htm and PHP mixed
2, a statement to; (semicolon ends)
3, how to define a variable, and the use of variables
(2), PHP data operation type
Four scalar types:
Boolean (Booleans) understood as true or false
Integer (integral type)
Float (floating-point type, also "double") is interpreted as a decimal type
String (strings)
Two types of composite:
Array (arrays)
Object (Objects)
(3) PHP Five types of operations
1. Arithmetic operation
2, assignment operations (such as: $a =100)
3, Comparison operations (such as: $a < $b)
4, logical operation (such as: $a && $b)
5, incremental condensation operation (such as: $a + +)
(4) Switch conditional statement
Switch Conditional statement
<?php
$i = 1;
Switch ($i) {
Case 0;
The value of echo "I" is 0″;
Break
Case 1;
The value of echo "I" is 1″;
Break
Case 2;
The value of echo "I" is 2″;
Break
Default:echo "The above several values are not";
}
?>
Break n Jump Loop statement
Break n jump out of n-tier loops
Cases:
<?php
For ($i =1 $i <=5; $i + +) {
echo "i=". $i. " <br> ";
For ($j =1 $j <=5; $j + +) {
echo " j=". $j. " <br> ";
For ($k =1 $k <=5; $k + +) {
echo " k=". $k. " <br> ";
if ($k ==2) {
Break
}
}
if ($j ==3) {
Break 2;
}
}
echo "<br>";
}
?>
(5) Do While loop
<?php
Do a second judgment first.
do{
echo "Execution loop";
$a + +;
}while ($a >100);/note here's a semicolon.
echo "<br>";
To judge and execute first.
while ($a >100) {
echo "Execution loop";
$a + +;
}
?>
Functions that are commonly used in PHP arrays
foreach ($arr as $key => $val) {}//traversal array
Count ($arr)//counts the length of an array
Is_array ($arr)//array of Judgments
Explode ("key", $STR)//split string array