doujiepin5547 2011-05-11 00:40
浏览 258
已采纳

$ _POST中的变量以字符串而不是数组的形式返回

In my form i have fields with name photoid[] so that when sent they will automatically be in an array when php accesses them.

The script has been working fine for quite some time until a couple days ago. And as far as i can remember i havent changed any php settings in the ini file and havent changed the script at all.

when i try to retrieve the array using $_POST['photoid'] it returns a string with the contents 'ARRAY', but if i access it using $_REQUEST['photoid'] it returns it correctly as an array. Is there some php setting that would make this occur? As i said i dont remember changing any php settings lately to cause this but i might be mistaken, or is there something else i am missing.

  • 写回答

4条回答 默认 最新

  • duanchi5078 2011-05-11 00:52
    关注

    Raise your error_reporting level to find any potential source. It's most likely that you are just using it wrong in your code. But it's also possible that your $_POST array was mangled, but $_REQUEST left untouched.

    // for example an escaping feature like this might bork it
    $_POST = array_map("htmlentities", $_POST);
    // your case looks like "strtoupper" even
    

    To determine if your $_POST array really just contains a string where you expected an array, execute following at the beginning of your script:

    var_dump($_POST);
    

    And following for a comparison:

    var_dump(array_diff($_REQUEST, $_POST));
    

    Then verifiy that you are really using foreach on both arrays:

    foreach ($_POST["photoid"] as $id) { print $id; }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化