Search code examples
phpsuperglobals

Why does PHP not allow the use of a decimal value as a root key in $_SESSION?


Why does PHP not allow the use of a decimal value as a root key in $_SESSION?

For example...

$paper_num = '159339';
$mark = 'A';

$_SESSION[$paper_num][$mark];

... Doesn't work.


Solution

  • cant you save it in the session as an array eg..

    <?php
    session_start();
    $paper_num = '159339';
    $mark = 'A';
    
    $paper_detail = array(
    'paper_number'=> $paper_num,
    'paper_mark'=> $mark);
    
    $_SESSION['paper_details'] = $paper_detail;
    print_r($_SESSION['paper_details']);
    ?>