php中$_post[]取不到值怎么解决?
1、在php.ini 配置文件中,确保enable_post_data_reading值为on,这样才会自动将 post 数据填入 $_post 数组中。
2、检查头信息content-type是不是为“content-type:application/x-www-form-urlencoded 这种传输是以表单的方式提交数据php使用$_post方式接受。
如果头信息content-type为“content-type:application/json这种传输是以json方式提交数据,php需要使用file_get_contents(php://input)获取输入流的方式接受
3、确保使用本地apache服务器
例:如果用phpstorm自带的服务器,则$_post不能接收form传的数据,不知道原因
更多相关知识,请访问 !!
