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"" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> -----Original Message-----
> From: Yasuo Ohgaki [mailto:[EMAIL PROTECTED]]
> Sent: Monday, April 02, 2001 8:00 PM
> To: [EMAIL PROTECTED]
> 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 ([EMAIL PROTECTED])  ||  "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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to