首页  >  问答  >  正文

javascript - axios使用x-www-form-urlencoded,POST表单PHP提示过时

返回结果

Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0

1 如下的js会报过时

axios.post('/api/code/create', this.formItem)

2 如下的js不会报错

axios.post('/api/code/create', window.qs.stringify(this.formItem))

但是使用方法 2 的方式,this.formItem中的boolean数据会变成 "True" / "False"
导致存入数据库时 mysql 中字段类型为bool的字段无法将"True" 存为对应的 1 ,而始终是0

不想用修改php.ini这种方式,我使用的laravel5.2
获取数据的代码

Input::all();

该如何又避免报错,又能正确存储 ? 如果使用php://input 的方式,该如何修改?

过去多啦不再A梦过去多啦不再A梦2660 天前1016

全部回复(2)我来回复

  • PHP中文网

    PHP中文网2017-06-14 10:51:57

    不是 POST 表单过时。你是用的软件做的翻译吗?

    Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version.

    这句话的意思是 $HTTP_RAW_POST_DATA 常量过时了,并且会在下一个版本中移除。

    但是这个版本还有,这是一个警告

    后面给出了解决方案。

    2 种:

    • 在 php.ini 配置文件种,把 always_populate_raw_post_data 设置为 -1

    • 不要使用 $HTTP_RAW_POST_DATA,而是使用 php://input 代替。

    回复
    0
  • typecho

    typecho2017-06-14 10:51:57

    雷雷

    回复
    0
  • 取消回复