#23441 [Opn]: Session variables and ternary operator

From: Date: Thu, 01 May 2003 17:21:13 +0000
Subject: #23441 [Opn]: Session variables and ternary operator
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-38891@lists.php.net to get a copy of this message
ID: 23441 Updated by: helly@php.net Reported By: jeremy at wdonline dot com Status: Open Bug Type: Session related Operating System: Windows XP PHP Version: 4.3.1 New Comment: the ternary operator is bork Previous Comments: ------------------------------------------------------------------------ [2003-05-01 12:15:31] jeremy at wdonline dot com 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 this bug report at http://bugs.php.net/?id=23441&edit=1

« previous php.bugs (#38891) next »