使用php://input
就是一个输入流, 可以获得POST的原始数据.
echo file_get_contents("php://input");
//示例代码
//test.html
- <html>
- <head>
- <!--set title-->
- <title> test php://input </title>
- </head>
- <!--show page-->
- <body>
- <form action = "input.php" method="post">
- 用户名: <input type="text" name="user"> <br>
- 密码:<input type="password" name="password"> <br>
- <input type="submit">
- </form>
- </body>
- </html>
//input.php
- <html>
- <head>
- <!--set title-->
- <title> test php://iput web </title>
- </head>
- <!--show page-->
- <body>
- <?php
- echo"post data: <br>/n";
- echofile_get_contents("php://input");
- ?>
- </body>
- </html>