PHP Basics Overview _ PHP Tutorial

Source: Internet
Author: User
Tags float number php basics
PHP Basics overview. Php Basics the integer number in php is signed and cannot represent an unsigned integer. when the integer number exceeds the range, it is automatically converted from the integer number to the float number, you can use the php_int_size constant for php basic knowledge.

The integer number in php is signed and cannot represent an unsigned integer. when the integer number exceeds the range, it is automatically converted from the integer number to the float number, you can use the php_int_size constant to check the size of the php integer type, which is generally 4 bytes. Therefore, you can estimate the range of integer numbers, with the highest digit symbol bit. You can also use the php_int_max constant to view the maximum value of the int.

Tips:

1. when the variable is 0.0 or "0", it indicates false in both Boolean variables;

2. when a string variable is enclosed in double quotation marks, the variables and escape characters can be normally output according to the definition. when the single quotation marks are used to output content, the variable will be output as is, that is, the escape character or variable will not work, instead, the literal content is output as is. you can write your own code to see the difference. I personally think that the definition of php variables is a bit similar to that of js, because you don't need to specify any type at all. the type of php variables depends entirely on the type you actually use.

3. php arithmetic operators:

Note: the result obtained by the division sign "/" can be an integer or float. instead of an integer. for example, the result of 5/2 is 2.5, and the result in C is 2. When the results are different, 14 valid digits are displayed.

There are five operators: +,-, *,/, and %.

The symbols that link two strings are not the "+" sign in java, but the "point" sign. the "point" symbol automatically treats the variables before and after as strings.

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

The "=" symbol indicates that only the values on the left and right are true if they are equal.

The "=" symbol indicates that the values on the left and right are not only equal, but even the variable type should be equal to each other to return the true result.

Example:

$ A = 2;

$ B = 2.0;

In the above example, the values of $ a and $ B are equal, but the types are not equal! All use = true, use = is false.

$! = $ B Indicates that the result is true if the values of a and B are not equal or the types are not equal.

$! = $ B Indicates that the result is true only when the values of a and B are not equal.

$ A <> $ B indicates the meaning and $! = $ B is the same.

Echo $ a = $ B. the output content is not true or false. Instead, 0 and 1 represent true, and 0 represent false.

The >=and <=symbols indicate greater than or equal to, less than, or equal.

| There is a special logic judgment. when the current judgment is true, "|" the expression after the symbol will not be executed, so be careful! Similarly, the & symbol is similar. This phenomenon is called short circuit. Short-circuit and short-circuit are either representative. | The symbol can be replaced by or. Similarly, the & symbol can be replaced by and. However, there is a difference between English or and: the or operator is lower than =. For example

$ A = false | true; // a returns true;

$ A = false or true; // = "($ a = false) or true;

Var-dump ($ a, $ B );

Similarly, the and symbol is similar.

Type operator: instanceof, used to determine whether the data is an instance of a certain type. similar to java, true or false is returned.

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

The switch statement in php can be of the Boolean type in brackets! The string "0" is regarded as false. The default statement can be placed anywhere without affecting the execution sequence of other case statements! Even if it is placed in the first sentence of the switch statement. But remember to write the break statement.

Form submission problems:

In Firefox, when the form submission method is POST, the value of the field to be obtained is $ _ POST instead of $ _ REQUEST. in IE or Firefox, you can use $ _ REQUEST to obtain the content whether it is POST or GET. The $ _ REQUEST parameter corresponds to the name attribute value of the corresponding Input element of the form.

Differences between break statements in php:

First, you must understand what a loop is? A loop is a part of the braces of the for and while keywords called a loop. this is different from the braces of the if statement. The continue statement is generally placed in the if statement, this is generally used to skip the for loop or the while loop. Do not consider that braces in a for loop represent a loop. the braces in the if statement are not loops.

The break statement can be followed by a number indicating that it jumps out of the layer-7 loop. the brace area where the break statement is located is the first loop. Increment outward rather than ascending outward. Note that the number is too large to exceed the cycle of the outermost layer! For example, if there are only three layers of loops, but you have to skip four layers, this will lead to an error! By default, the number of bounce cycles is 1.

The continue statement ends the loop and skips the remaining code of the loop to start a new loop.

The goto statement is only valid in php5.3 or later versions.

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

Differences between variables and constants in php:

1. there is no dollar sign before the constant.

2. constants are defined by the define () function or const, and cannot act as the left value of the value assignment statement.

3. constants can be used and accessed anywhere regardless of the scope of the variable.

4. once defined, constants cannot be redefined or undefined.

5. constant values are scalar [basic data types float, int, string, and boolean ].

Define two forms of a constant:

Define ("INT_MAX", 255) or const INT_MAX = 255; you cannot add a dollar sign before a constant or assign a value again.

The integer number in php is signed and cannot represent an unsigned integer. when the integer number exceeds the range, it is automatically converted from the integer number to the float number, you can use the php_int_size constant...

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.