Hello Tedd,
tedd schrieb:
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
Yes, our mails overlaped each other (Do you say that in english? My
english is not the best.)
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?
My citation is just a part of what you found.
By the way: I tried your initial code and I had no problem with the
variable declared after the numeric ones. (your $_SESSION['test']). I
tried on a Version 5.2.5 an Win XP.
Cheers,
Sabine
Cheers,
tedd
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php