Re: [PHP-DEV] Bug #1235: string arithmetical misbehaviour From: Andi Gutmans (andi <email protected>)
Date: 03/15/99

At 11:13 15/03/99 -0000, tolj <email protected> wrote:
>From: tolj <email protected>
>Operating system: Linux 2.0.36
>PHP version: 3.0.7
>PHP Bug Type: Misbehaving function
>Bug description: string arithmetical misbehaviour
>
>what about this misbehaviour of string arithmetics:
>
>$foo = "04";
>$foo++;
>echo $foo; ## reports "05"
>
>$foo = "04";
>$foo--;
>echo $foo; ## reports "3" without leading zero !!
>
>I suppose both should react the same, or am I wrong?!

I tried to close the bug in the bugs database but my password doesn't seem
to work anymore. Any ideas? Where has the username field gone? :)
-----------------------------------------------------------------
Only increment works with strings in PHP, decrement doesn't. When you
decrement a string it gets
converted to a long and is then decremented.
The reason is that like Perl, we didn't see much use for string
increment/decrement except for testing purposes and creating unqiue ideas
so increment should be enough.

Andi

---
Andi Gutmans <andi <email protected>>
ICQ: 1568297
PGP: finger andi <email protected>

-- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe <email protected> For help: php-dev-help <email protected>