Re: Why does it work this way?
| From: | Yasuo Ohgaki | Date: | Tue, 03 Apr 2001 16:24:38 +0000 |
| Subject: | Re: Why does it work this way? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-46841@lists.php.net to get a copy of this message | ||
I didn't read carefully yours and original post. Sorry.
Anyway,
warn_plus_overloading = On ; warn if the + operator is used with strings
does not raise warnings on my PHP4.0.4pl1 for some reason.
I think incrementing strings should results in 1 if type juggling works as
documented.
--
Yasuo Ohgaki
""Mark Roedel"" <MarkRoedel@letu.edu> wrote in message
news:E162F01D7D84F645924A046DA1FE60F30E982D@rachael.letnet.net...
> -----Original Message-----
> From: Yasuo Ohgaki [mailto:yohgaki@hotmail.com]
> Sent: Monday, April 02, 2001 8:00 PM
> To: php-general@lists.php.net
> Subject: Re: [PHP] Why does it work this way?
>
>
> I guess PHP is doing this
>
> $str = "a";
> $str++;
>
> as
>
> $str = "a";
> $str = $str + $str; // $str now stores "aa"
On my installation of PHP (4.0.4pl1, Apache 1.3.17, FreeBSD 4.2-STABLE),
the above snippet results in $str storing a zero value. (Which makes
sense. The numerical value of "a" is zero.)
However
$str = "a";
$str++;
results in $str storing the value "b".
It's
$str = "z";
$str++;
that results in "aa" being stored in $str.
(This behavior was, in fact, what started the thread you replied into.)
---
Mark Roedel (roedelm@letu.edu) || "There cannot be a crisis next week.
Systems Programmer / WebMaster || My schedule is already full."
LeTourneau University || -- Henry Kissinger
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net