为什么不能使用字符串编号作为会话变量中的索引?

why can't you use a string number as a index in the session variable?

示例:

$_SESSION['10'] = 'testing';
echo $_SESSION['10'];

上面不会打印出任何东西...我发现(经过长时间的挫折)你不能使用字符串数字作为 $_SESSION 变量的索引。有人知道为什么吗?

引自here

The PHP session storage mechanism was originally built around "registering" variables, so the keys in $_SESSION must be names that could be treated as variables in their own right. This means that $_SESSION[10] is invalid, because </code> wouldn't be a valid variable name, and since <code>$foo[10] and $foo['10'] refer to the same thing, $_SESSION['10'] is invalid as well.