dougan0529 2012-05-10 19:09
浏览 47
已采纳

php会话变量多维关联数组问题

I've looked around SO, but can't find an explanation to what is going on in my $_SESSION variables.

@ob_start();
$k=@ob_get_contents();
@ob_end_clean();
@session_start();
unset($s,$m);
$m1 = explode(" ", microtime());
$stime = $m1[1] + $m1[0];
echo $k;

$_SESSION['resendConfirmation']['function'] = 'resend';
$_SESSION['resendConfirmation']['id'] = '8';                

print_r($_SESSION);

outputs:

Array ( [resendConfirmation] => 8esend ) 

Why is it string replacing? I've never had this issue before.

What I want is thus:

Array([resendConfirmation] => Array(
                             [id] =>8
                             [function} => resend
                             )
)

I've never had this happen before, I'm totally confused!

UPDATE In response to @DanRedux I've changed to two non-existent variable names to take the referencing out of the equation, still the same result...

$_SESSION['resendConfirmation']['tweak'] = 'resend';
$_SESSION['resendConfirmation']['tweak2'] = '8';

Same result :(

Did a sitewide query of resendConfirmation and none were found, but once I change that array name, it all worked, baffled, but fixed...

$_SESSION['reConfirm']['function'] = 'resend';
$_SESSION['reConfirm']['id'] = '8';             

print_r($_SESSION);
  • 写回答

2条回答 默认 最新

  • duanchuli5647 2012-05-10 19:22
    关注

    Since I dont really know what other sorts of shenanigans the code is up to outside of this block you gave us I would say to just try this instead:

    $_SESSION['resendConfirmation'] = array('id' => 8, 'function' => 'resend');
    

    If this also fails then there has to be something else going on outside of what you posted. Good luck!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题