web开发 Django开发交流群:19525555 注册 | 登陆

"php://input" 例子

php://input

是一个输入流,可以获得 POST 的原始数据;

用法: echo file_get_contents("php://input");

例子:

a.html

XML/HTML代码
  1. <form  action="b.php"  method="post">        
  2.      <input   type="text"   name="user">        
  3.      <input   type="password"   name="password">        
  4.      <input   type="submit">        
  5. </form>  
b.php:

PHP代码
  1. <?php       
  2. header("Content-Type:text/html; charset=utf-8");     
  3. $file_in   =   file_get_contents"php://input");      
  4. echo   urldecode($file_in);      
  5. file_put_contents('php://output',$file_in);      
  6. //$doc   =   new   DOMDocument();      
  7. //$doc   ->   loadXML($file_in);      
  8. ?>   

Tags: php

« 上一篇 | 下一篇 »

Trackbacks

点击获得Trackback地址,Encode: UTF-8

发表评论

评论内容 (必填):