I ++-php Tutorial

Source: Internet
Author: User
I ++ int & nbsp; I & nbsp; 3; I & nbsp; + & nbsp; I ++ & nbsp; + & nbsp; ++ I; the above code outputs 11 in JavaC # JavaScript, but 12 in PHP. what is the difference between PHP computing and other three? Think Twice. please give me some advice! -I ++ problems
Int I = 3;
I = I + I ++ I;
The above code outputs 11 in both Java/C #/JavaScript, but 12 in PHP. what is the difference between PHP computing and three for him? Think Twice. please give me some advice!


------ Solution --------------------
$ I = 3;
$ A = $ I + $ I ++ $ I;
Echo $ a; // 12
This is a php BUG.
It seems that all php5 has this problem (at least three versions at hand)
The problem lies in the first $ I value transfer method, such as writing
$ I = 3;
$ A = ($ d = $ I) + $ I ++ $ I;
Echo $ a; // 11
That's correct.
Obviously, the first $ I is passed as a reference, because the following $ I ++ is actually involved in the operation of 4 rather than 3

Remove ++ $ I to make it clearer.

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.