An entry-level PHP basic grammar and data type article, I hope you can provide some help PHP beginners OH.
PHP basic syntax and data types:
(1), PHP basic syntax:
1, htm and PHP mixed
2, a statement to; (End of semicolon)
3, how to define a variable, and the use of variables
(2), PHP data operation type
Four types of scalar:
Boolean (Boolean) understood as true and false
Integer (integer type)
Float (floating point type, also "double") understood as decimal type
String (String)
Two kinds of composite types:
Array (arrays)
Object (Objects)
(3) PHP Five types of operations
1. Arithmetic operations
2. Assignment operation (e.g. $a =100)
3. Comparison operations (e.g. $a < $b)
4. Logic operations (e.g. $a && $b)
5, increment the coagulation decrement operation (for example: $a + +)
(4) Switch condition statement
Switch condition statement
$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 "A few values above are not";
}
?>
Break n jump out of a looping statement
Break n jumps out of n-layer loops
Cases:
for ($i =1; $i <=5; $i + +) {
echo "i=". $i. "
”;
for ($j =1; $j <=5; $j + +) {
echo "j=". $j. "
”;
for ($k =1; $k <=5; $k + +) {
echo "k=". $k. "
”;
if ($k ==2) {
Break
}
}
if ($j ==3) {
Break 2;
}
}
echo "
”;
}
?>
(5) Do and loop
Perform a second judgment first
do{
echo "Execution loop";
$a + +;
}while ($a >100);//Note there's a semicolon here.
echo "
”;
Judge and execute first.
while ($a >100) {
echo "Execution loop";
$a + +;
}
?>
Functions commonly used in PHP arrays
foreach ($arr as $key = + $val) {}//traversal array
Count ($arr)//The length of the statistic array
Is_array ($arr)//judgment array
Explode ("key", $STR)//split string array
http://www.bkjia.com/PHPjc/632633.html www.bkjia.com true http://www.bkjia.com/PHPjc/632633.html techarticle an entry-level PHP basic grammar and data type article, I hope you can provide some help PHP beginners OH. PHP basic syntax and data type: (1), PHP basic syntax: 1 、...