At 2:09 PM +0200 8/16/08, Sabine Richter wrote:
Hello Tedd,

it seems to be a naming problem. You may not use a numeric value for a variable name to store in $_SESSION.

By assigning it to $_SESSION, you get a
Notice: Unknown: Skipping numeric key 1 in Unknown on line 0

and in your second script a
Notice: Undefined offset: 1 in yourpath\index1.php on line XX -> whatever line it was in your script

If you define
$_SESSION['var'.$i] = $i;
or $_SESSION[$i.'var'] = $i;
or even $_SESSION[$i.'.1'] = $i;
the $_SESSION won't forget your vars on the way to script 2.

But it's a bit strange, that you can use your numeric keys in script 1.

I tried with other Superglobals like $_POST and $_COOKIE and they seem to accept numeric variable names.

So, is that a php bug?
But as the docu says "A valid variable name starts with a letter or underscore", I think you can not complain about it.

Cheers
Sabine

Sabine:

You hit the nail right on the head.

I discovered that fact this morning and posted an answer already. Here's the demo:

http://www.webbytedd.com/b2/session-test1/index.php

I read everything I could find about sessions, but didn't come across:

"A valid variable name starts with a letter or underscore"

To the contrary, this is only what I found:

Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores

Where did you see that?

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to