RE: [PHP] Why does it work this way?

From: Date: Tue, 03 Apr 2001 13:40:16 +0000
Subject: RE: [PHP] Why does it work this way?
Groups: php.general 
Request: Send a blank email to php-general+get-46810@lists.php.net to get a copy of this message
> -----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

« previous php.general (#46810) next »