Re: PHP 4.0 Bug #5331: ++ operator

From: Date: Sat, 01 Jul 2000 19:23:04 +0000
Subject: Re: PHP 4.0 Bug #5331: ++ operator
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-23167@lists.php.net to get a copy of this message
At 09:14 PM 7/1/00 +0200, Lukasz Michalski wrote:
Andi Gutmans wrote: Can you do var_dump($newkey) after the list() line and tell us what the output is? My guess is that $newkey isn't an integer and therefore it is behaving differently than you expect it to behave. Might be a misfeature but then again it might not. Once we know what the type is we can think if what's happening makes sense or not. Andi It returns: string(20) "1 " (19 spaces in page source) Now I see why this happened. I should set $newkey to integer before incrementing it but, it shouldn't be that $var = $var + sth behaves diffrient that $var++. I think it should be changed that all variants behaves the same way.
Is that "1 " with a space after the 1? Don't forget that incrementing a string has a special meaning in PHP and therefore it behaves differently than adding it with an integer. If there weren't a space after the 1 then it should increment the string to "2". Andi --- Andi Gutmans <andi@zend.com> http://www.zend.com/

« previous php.dev (#23167) next »