PHP Basics Introduction _php Tutorial

Source: Internet
Author: User
Tags float number php basics
The number of shapes in PHP is signed, can not represent unsigned integers, when the number of shapes out of range, will be automatically converted from shaping to float number, you can use the Php_int_size constant to see the php integer type of bytes, generally 4 bytes, so you can estimate the range of shaping number, The maximum number of digit sign bits. You can also use the Php_int_max constant to view the maximum value of an int.

Small Knowledge Points:

1. When the variable is 0.0 or "0" in the Boolean variable, it means false;

2. String variables in double quotation marks when the variable and escape character can be normal output according to its definition, and the single quote output content when it will output its contents, that is, the escape character or variable will not work, and will only output literal content, this can write the code to see the difference. Personally feel PHP variable definition is a bit like JS, because you do not need to specify any of its types, its type depends entirely on the actual type you use.

3. Arithmetic Operators for PHP:

Note: The result of Division sign "/" can be either an integer or a float. Instead of just integers, for example 5/2 the result is 2.5, and in c the result is 2. When the results are not endless, the results show 14 significant digits.

Operators have a total of + 、-、 *,/, and% five operators.

The symbol that links two strings is not a + sign in Java, but instead. Point number, the dot will automatically treat the variable as a string.

The difference between the "= =" symbol and "= = =":

the "= =" symbol indicates that only the left and right values are equal to be true.

the "= = =" symbol indicates that both the left and right values are equal, and even variable types should be equal to return true.

The following example:

$a = 2;

$b = 2.0;

The values of $ A and $b variables in the above example are equal, but the types are not equal! all use = = is true, with = = = False.

$a!== $b indicates that the result is true whenever a and B values are unequal or if the type is unequal.

$a! = $b indicates that the result is true only if the values of a and B are not equal.

$a <> $b represents the same meaning as $a! = $b.

echo $a = = The content of the $b output is not true or false. Instead, 0 and 1, and 1 for true,0, represents false.

There are also >=, <= symbols that are greater than or equal to, less than or equal to each other.

|| Logical judgment has a special, when the previous judgment is true, "| |" The expression after the symbol is not executed, so be careful! The same is also the case with the && symbol. This phenomenon is called a short circuit. Short-circuit and short-circuit or is the representative thereof. | Symbols can be substituted with or. The same && symbol can be substituted with and. But the OR and and in English is a bit different: the OR operator is lower than = low. For example

$a = False | | True A returns true;

$a = False or true; = "($a = false) or true;

Var-dump ($a, $b);

The same is also the case with the same and symbol.

Type operator: instanceof, used to determine if the data is a class of instances, similar to Java, the result returns TRUE or FALSE.

The + + and-operators are only for variables and cannot be used on constants!

The switch statement in PHP can be a Boolean type in parentheses! The string "0" is considered false. The default statement can be placed anywhere without affecting the order in which other case statements are executed! Even if the first sentence in the switch statement is placed. But be careful to remember to write the break statement.

Form Submission Questions:

In Firefox, when the form is submitted as a post, the appropriate way to get the field is $_post, not $_request, and in IE or Firefox, either POST or get can use $_request to get the content. The $_request parameter corresponds to the Name property value of the form's corresponding INPUT element.



The break statements in PHP differ in the following points:

First you must understand what a cycle is. A loop is a part of a for and while keyword that is called a loop, which is different from the curly brace of the IF statement, which is typically used in an if statement to skip this loop of the for loop or the current loop of the while loop. Continue Do not assume that the curly braces in the For loop represent a loop, and the curly braces under the If statement are not loops.

A break statement can be followed by a number indicating that it jumps out of the first layer of the loop, with the curly brace area in which the break statement is used. Sliding scale outward, instead of ascending from outside. But notice that the numbers are too big to go beyond the outermost loop! For example, there are only 3 layers of loops, you have to jump 4 layers, this will be wrong! The break default out-of-loop layer is 1.

The continue statement is used to end the loop, skipping the rest of the loop to start a new loop.

Goto statement is valid only in php5.3 or later

Goto: A break statement used to jump out of a loop instead of a multiple loop. Make the code more concise!

The difference between variables and constants in PHP:

1. There is no dollar sign in front of constants.

2. Constants are defined by the Define () function or const and cannot act as an lvalue to an assignment statement.

3. Constants can be used and accessed everywhere regardless of the scope of the variable.

4. Once a constant is defined, it cannot be redefined or de-defined.

5. The value of the constant is a scalar "base data type float, int, string, boolean".

Define two forms of a constant:

Define ("Int_max", 255) or const int_max=255; cannot be added to the dollar symbol before the constant, nor can it be re-assigned.

http://www.bkjia.com/PHPjc/313616.html www.bkjia.com true http://www.bkjia.com/PHPjc/313616.html techarticle the number of shapes in PHP is signed, can not represent unsigned integers, when the number of shapes out of range, will be automatically converted from the number of shaping to float number, you can use the Php_int_size constant to view the PHP integer class ...

  • 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.