note 40565 deleted from ref.session by nlopess
| From: | nlopess@php.net | Date: | Mon, 08 Mar 2004 17:15:11 +0000 |
| Subject: | note 40565 deleted from ref.session by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-66449@lists.php.net to get a copy of this message | ||
Note Submitter: code at dearneighbor dot com
----
This is in response to 'andreas dot agren at home dot se' post.
It clearly states on this page, in the "Examples" area, just under "Predefined
Constants" and "SID" area, the following:
"The keys in the $_SESSION associative array are subject to the same limitations as regular
variable names in PHP, i.e. they cannot start with a number and must start with a letter or
underscore. For more details see the section on variables in this manual."
Here's the same link for that variable section:
http://www.php.net/manual/en/language.variables.php
If you don't follow the basic rules of PHP, you can expect unpredictable results.
FYI: You can trick PHP into using variable names that contain a period. I don't recommend it,
but here are two ways to do it:
// First way:
$dynamic_var = "a.car";
$$dynamic_var = "Mustang";
echo $$dynamic_var; // Displays: Mustang
// Second way:
${"a.car"} = "Corvette";
echo ${"a.car"}; // Displays: Corvette
If there's an array key with a period in it, like in $_GET, the PHP parser will convert that to
an underscore. Example: $_GET["nice.try"] will be converted to
$_GET["nice_try"].
I hope that helps someone.