Re: PHP_SESSION_* constant values
| From: | Paul Dragoonis | Date: | Sat, 28 Jan 2012 20:43:01 +0000 |
| Subject: | Re: PHP_SESSION_* constant values | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-57542@lists.php.net to get a copy of this message | ||
On Sat, Jan 28, 2012 at 7:17 PM, Justin Martin <frozenfire@php.net> wrote:
> Hello everyone,
>
> For the result of session_status(), the corresponding constants for the
> sessions state are
>
> - PHP_SESSION_DISABLED = 0
> - PHP_SESSION_NONE = 1
> - PHP_SESSION_ACTIVE = 2
>
> I'd like to suggest we change these values to
>
> - PHP_SESSION_DISABLED = -1
> - PHP_SESSION_NONE = 0
> - PHP_SESSION_ACTIVE = 1
>
> This way, one can do if(session_status()) to check if there is an active
> session, rather than having to compare the result to a constant.
>
> Any objections?
I believe comparing the value against a constant, is always more
readable than wondering what "truthy" means. if(session_status() ===
PHP_SESSION_ACTIVE) is much self-documenting than the proposed change.
Therefore I object to this change.
- Paul
>
> Thanks,
> Justin Martin
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>