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

StackOverflow https://stackoverflow.com/questions/18545758

  •  26-06-2022
  •  | 
  •  

سؤال

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.

هل كانت مفيدة؟

المحلول

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']);
?>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top