ID: 20548 Comment by: lew at mailduct dot com Reported By: prgallier at yahoo dot com Status: Wont fix Bug Type: Scripting Engine problem Operating System: Linux 2.4 PHP Version: 4.3.2-dev New Comment:
"IMO, using unitialized variables should cause a FATAL error. Just initialize the variables you use." You miss the point. This is not about uninitialized variables. It is about a GROSS difference between how the increment and decrement operators work! Either *both* operations should fail with uninitialized variables (for consistency and sanity), or *both* operations should succeed (again, for the same reason). By simply saying, "initialize your variables" you avoid looking at the underlying problem and instead apply a band-aid. Band-aids are not a good thing... they come back to bite you later. If "plus" works a certain way, you'd expect "minus" to work the same (meaning, within the same framework of rules). All we are saying is, make them consistent! Previous Comments: ------------------------------------------------------------------------ [2003-09-27 20:01:38] prgallier at yahoo dot com There are plenty of workarounds, but the problem is the lack of consistency. Either you can or you can't use uninitialized variables. If you can use $test[0]++ you should be able to use $test[0]-- as well (no, I don't think they should drop the ability to use direct increments/decrements). ------------------------------------------------------------------------ [2003-09-27 16:47:47] [EMAIL PROTECTED] IMO, using unitialized variables should cause a FATAL error. Just initialize the variables you use. ------------------------------------------------------------------------ [2003-09-27 14:38:53] lew at mailduct dot com PHP 4.3.3 on FreeBSD 4.8-RELEASE: <?php // Increment some blank/empty variables... $pos++; $pos++; $pos++; $neg--; $neg--; $neg--; // Show them to us now... print( "pos = $pos\n" ); print( "neg = $neg\n" ); // Now do it another way (forced typecast)... $ppp += 1; $ppp += 1; $ppp += 1; $nnn -= 1; $nnn -= 1; $nnn -= 1; // Show them to us now... print( "ppp = $ppp\n" ); print( "nnn = $nnn\n" ); # # Expected: # pos = 3 ppp = 3 # neg = -3 nnn = -3 # # Actual: # pos = 3 ppp = 3 # neg = nnn = -3 ?> ------------------------------------------------------------------------ [2003-09-27 14:36:59] lew at mailduct dot com This is a GROSS inconsistency in how the increment/decrement operators work, and one that coders are likely to stumble upon the hard way. Please study the effect of fixing this, at the expense of breaking a long-time quirk in BC. Breaking a quirk, and documenting it on the BC page, is better than maintaining a GROSS inconsistency in one of the basic language construct operators! Please fix this! ------------------------------------------------------------------------ [2003-08-03 12:57:49] [EMAIL PROTECTED] This is a valid bug, however a fix would be a BC break that would result in a beahviour change that was in place since 3.0 days. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/20548 -- Edit this bug report at http://bugs.php.net/?id=20548&edit=1