note 40565 added to ref.session

From: Date: Mon, 08 Mar 2004 03:19:48 +0000
Subject: note 40565 added to ref.session
Groups: php.notes 
Request: Send a blank email to php-notes+get-66420@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/ref.session.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40565 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40565&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40565&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#66420) next »