NYCPHP Meetup

NYPHP.org

[nycphp-talk] TRUE/FALSE and $_SESSION variables

Kenneth Downs ken at secdat.com
Wed Jul 11 22:57:24 EDT 2007


"false" is a keyword, same as "true" and "null".


> This tiny script:
> <?php
> session_start();
> $ineligibleFlag = FALSE;

This assigns $ineligibleFlag the boolean value of 0 or "false"

> if ( $ineligibleFlag === FALSE ) echo 'it is false<br />';

This tests to see if $inelegibleFlag is boolean and false (triple equals 
requires type and value to match), which is exactly what you just 
assigned it to, so you get a match.

Try assigning $ineligibleFlag = 0, or '0' , or '' (empty string) and see 
the various results you get.

> $_SESSION['ineligibleFlag'] = FALSE;
> print_r( $_SESSION );
>
> produces this output:
> it is false
> Array ( [ineligibleFlag] => )
>
> The docs tell me that sessions can handle everything that can be 
> serialized, and that serialize can handle everything but resources, 
> and that I shouldn't define resource constants.  But FALSE is not a 
> resource that I know of, and so none of that explains (that I can see, 
> anyway) why the session can't hold this value. I can easily work 
> around this, but I'd like to understand it as well.
>
> Michael Southwell, Vice President for Education
> New York PHP
> http://www.nyphp.com/training - In-depth PHP Training Courses
>
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php


-- 
Kenneth Downs
Secure Data Software, Inc.
www.secdat.com    www.andromeda-project.org
631-689-7200   Fax: 631-689-0527
cell: 631-379-0010




More information about the talk mailing list