#23441 [NEW]: Session variables and ternary operator
| From: | jeremy at wdonline dot com | Date: | Thu, 01 May 2003 17:15:31 +0000 |
| Subject: | #23441 [NEW]: Session variables and ternary operator | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-38890@lists.php.net to get a copy of this message | ||
From: jeremy at wdonline dot com
Operating system: Windows XP
PHP version: 4.3.1
PHP Bug Type: Session related
Bug description: Session variables and ternary operator
Through many frustrating hours, I think found a bug. The current session
documentation offers this example for setting session variables using the
$_SESSION array:
if (!isset($_SESSION['count'])) {
$_SESSION['count'] = 0;
} else {
$_SESSION['count']++;
}
This example, of course, works. However, it is common knowledge the the
ternary operator can achieve the same results in one line:
$_SESSION['count'] =
(!isset($_SESSION['count']))?0:$_SESSION['count']++;
However, this does not work. The session variable always seems to not be
set, as it always retains the value of 0 instead of being incremented.
--
Edit bug report at http://bugs.php.net/?id=23441&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=23441&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=23441&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=23441&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=23441&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=23441&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=23441&r=support
Expected behavior: http://bugs.php.net/fix.php?id=23441&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=23441&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=23441&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=23441&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23441&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=23441&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=23441&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=23441&r=gnused