web - If you understand the PHP fastcgi protocol, you can't get $_POST?
高洛峰
高洛峰 2017-05-18 10:48:36
0
1
552

Implement an http server, and use fastcgi protocol to communicate with php-fpm when supporting php

To implement the get request, send QUERY_STRING and SCRIPT_FILENAME to php-fpm, and the server returns the result, which is normal here.

The post request is implemented by sending the content-length field and body content to the fastcgi server, and then the server returns the result. Like the following

Form code

<html>
<body>
<form action = "file.php" method  = "POST" >
    <input type="text" name="age" />
    <input type="submit"  />
</form>
</body>
</html>

php code

<?php
var_dump($_POST['age']);

Parameters sent

SCRIPT_FILENAME : /home/tan/Demo/studyHttpd/htdocs/file/file.php
REQUEST_METHOD : POST
QUERY_STRING : 
CONTENT_TYPE : application/x-www-form-urlencoded
CONTENT_LENGTH : 7

The body sent is , which is the content in the form

age=123

Why does php-fpm return NULL?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(1)
PHPzhong

You print separately$_POST$_REQUEST
that is:

var_dump($_POST);
var_dump($_REQUEST);
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!