dprntkxh703029 2011-04-13 19:43
浏览 76
已采纳

PHP:将Array值转换为变量

I´m making a form, and I want to change the value of the POST into a variable. But I'm doing it wrong somehow.

Check the sample:

$_POST['name'] = $name;
$_POST['age'] = $age;
$_POST['country'] = $country;

This error pops: Parse error: syntax error, unexpected T_VARIABLE on the first $_POST

  • 写回答

5条回答 默认 最新

  • dspvin19712 2011-04-13 19:58
    关注

    While everyone else is entirely correct to point that you shouldn't be assigning values to the $_POST superglobal, it is possible for you to make such an assignment. The $_POST superglobal is just an array, after all, and so it acts like one.

    The error you're seeing is because PHP is recognizing $_POST['name'] as being part of the previous statement. Check to make sure that you have properly ended the previous statement (i.e. the line before $_POST['name'] = $name ends with a ;).

    You probably do want to be assigning $_POST['name'] to a variable, rather than the other way around as you have it now, but that's not what's causing the error.

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

报告相同问题?

悬赏问题

  • ¥15 三菱FX系列PLC串口指令
  • ¥15 cocos的js代码调用wx.createUseInfoButton问题!
  • ¥15 关于自相关函数法和周期图法实现对随机信号的功率谱估计的matlab程序运行的问题,请各位专家解答!
  • ¥15 Python程序,深度学习,有偿私
  • ¥15 扫描枪扫条形码出现问题
  • ¥35 poi合并多个word成一个新word,原word中横版没了.
  • ¥15 【火车头采集器】搜狐娱乐这种列表页网址,怎么采集?
  • ¥15 求MCSCANX 帮助
  • ¥15 机器学习训练相关模型
  • ¥15 Todesk 远程写代码 anaconda jupyter python3