Re: [PHP-DEV] PHP 4.0 Bug #5331: ++ operator From: Andi Gutmans (andi <email protected>)
Date: 07/01/00

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 <email protected>>
http://www.zend.com/

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>