|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-03-20 10:02 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 06 11:00:02 2025 UTC |
Description: ------------ Applying the increment operator (++) on a variable (containing a number) ending with a newline character doesn't change the variable. However, applying += 1 to the same variable does result in the right behaviour. Reproduce code: --------------- function showsucc($x) { // using increment operator $tmp = $x; $tmp++; echo "successor of $x = ",$tmp,"\n"; // using plus operator $tmp = $x; $tmp += 1; echo "result of $x + 1 = ",$tmp,"\n"; } showsucc("123\n"); showsucc("123"); Expected result: ---------------- successor of 123 = 124 result of 123 + 1 = 124 successor of 123 = 124 result of 123 +1 = 124 Actual result: -------------- successor of 123 = 123 <---- difference is here result of 123 + 1 = 124 successor of 123 = 124 result of 123 + 1 = 124