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条)

报告相同问题?

悬赏问题

  • ¥30 关于#opencv#的问题:使用大疆无人机拍摄水稻田间图像,拼接成tif图片,用什么方法可以识别并框选出水稻作物行
  • ¥15 Python卡尔曼滤波融合
  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥20 能提供一下思路或者代码吗
  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1