PHP Basic grammar and data type Learning Notes _php Tutorial

Source: Internet
Author: User
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 、...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.