function call problem, floating point, Operation Priority, and short-circuit "This is the key", the use of bitwise operations

Source: Internet
Author: User

1. The meaning of the return value in a call to a function
Function F1 () {
echo 1234;
Return 123;//here to handle the returned value
}
Var_dump (F1 ());//Here is an understanding of the entire return value "function calls without a return value will not affect execution, only the results have effect"

2. Floating-point number representation "Double precision: eight bytes required to represent"
"Do not use floating-point numbers to compare, that is because the floating point conversion of the binary system will have problems, not simply to compare"


3.echo "Hello, $arr [' name '];//The array elements here are not parsed correctly and need to use {} packages to ensure correct parsing
However, for attributes in an object, you can parse it directly within double quotes
Things that double quotes can parse: Variables, object properties, but unable to parse array element cases
However, in double quotes, you cannot "intelligently" determine the boundary problem "using {} as a split method"
Connector is faster than {} Resolution

Single-byte characters: English and Numbers "can be directly taken as a string array directly by location"
The character set "specifies a combination of encodings to form a stable character graph with encoding for mapping UTF8"


4. If the constant exists, then output, if the constant does not exist, the constant name will be converted to a string
"Impact on performance"


5. Short-circuiting and precedence in the operator "logical vs."
There are exceptions to the short-circuit operation
Var_dump (true | | true&&false);//There is no short-circuit operation in this case, but priority needs to be considered
Var_dump (true | | a=1);//A short-circuit operation in this case


6. Reasons for the difference between pre-Gaga and post-gaga:
The return value is different.
$a = $b ++;//The process is like this

And the effect of the pre-Gaga is to return the value of the incremented $b

7. Use @ as the error suppressor in applications that request resources


8. Bitwise operations
and the conversion of problems in the system
Increase the speed, and can make the number of the marked bits into a binary number, and then bitwise operation, get the status code at the specified position, get the final result

You can reduce the content store by marking the options for the multi-box by the number of digits.

function call problem, floating point, Operation Priority, and short-circuit "This is the key", the use of bitwise operations

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.