Maison > php教程 > php手册 > file_get_contents()的另一种使用方法,filegetcontents

file_get_contents()的另一种使用方法,filegetcontents

WBOY
Libérer: 2016-06-13 09:06:53
original
1631 Les gens l'ont consulté

file_get_contents()的另一种使用方法,filegetcontents

今天在网上看到一篇挺不错的文章,拿过来保存学习一下。本文源地址为:http://www.kuitao8.com/20140727/2867.shtml

$data = file_get_contents("php://input");

<span class="php-hl-code">    <span class="php-hl-identifier">php<span class="php-hl-code">:<span class="php-hl-comment">//<span class="php-hl-comment">input 是个可以访问请求的原始数据的只读流。 POST 请求的情况下,最好使用 php://input 来代替 $HTTP_RAW_POST_DATA,因为它不依赖于特定的 php.ini 指令。 而且,这样的情况下 $HTTP_RAW_POST_DATA 默认没有<span id="12_nwp">填充, 比激活 always_populate_raw_post_<span id="13_nwp">data 潜在需要更少的内存。 enctype="multipart/form-data" 的时候 php://input 是无效的。 
    
 
<span class="php-hl-number">1<span class="php-hl-code">, <span class="php-hl-identifier">php<span class="php-hl-code">:<span class="php-hl-comment">//<span class="php-hl-comment">input 可以读取http entity body中指定长度的值,由Content-Length指定长度,不管是POST方式或者GET方法提交过来的数据。但是,一般GET方法提交数据 时,http request entity body部分都为空。 
<span class="php-hl-number">2<span class="php-hl-code">,<span class="php-hl-identifier">php<span class="php-hl-code">:<span class="php-hl-comment">//<span class="php-hl-comment">input 与$HTTP_RAW_POST_DATA读取的数据是一样的,都只读取Content-Type不为multipart/form-data的数据。<span class="php-hl-code">
学习<span id="11_nwp">笔记
 <span class="php-hl-number">1<span class="php-hl-code">,<span class="php-hl-identifier">Coentent<span class="php-hl-code">-<span class="php-hl-identifier">Type<span class="php-hl-code">仅在取值为<span class="php-hl-identifier">application<span class="php-hl-code">/<span class="php-hl-identifier">x<span class="php-hl-code">-<span class="php-hl-identifier">www<span class="php-hl-code">-<span class="php-hl-identifier">data<span class="php-hl-code">-<span class="php-hl-identifier">urlencoded<span class="php-hl-code">和<span class="php-hl-identifier">multipart<span class="php-hl-code">/<span class="php-hl-identifier">form<span class="php-hl-code">-<span class="php-hl-identifier">data<span class="php-hl-code">两种情况下,<span class="php-hl-identifier">PHP<span class="php-hl-code">才会将<span class="php-hl-identifier">http<span class="php-hl-code">请求数据包中相应的数据填入全局变量<span class="php-hl-var">$_POST 
 <span class="php-hl-number">2<span class="php-hl-code">,<span class="php-hl-identifier">PHP<span class="php-hl-code">不能<span id="10_nwp">识别的<span class="php-hl-identifier">Content<span class="php-hl-code">-<span class="php-hl-identifier">Type<span class="php-hl-code">类型的时候,会将<span class="php-hl-identifier">http<span class="php-hl-code">请求包中相应的数据填入变量<span class="php-hl-var">$HTTP_RAW_POST_DATA 
 <span class="php-hl-number">3<span class="php-hl-code">, 只有<span class="php-hl-identifier">Coentent<span class="php-hl-code">-<span class="php-hl-identifier">Type<span class="php-hl-code">为<span class="php-hl-identifier">multipart<span class="php-hl-code">/<span class="php-hl-identifier">form<span class="php-hl-code">-<span class="php-hl-identifier"><span id="9_nwp">data<span class="php-hl-code">的时候,<span class="php-hl-identifier">PHP<span class="php-hl-code">不会将<span class="php-hl-identifier">http<span class="php-hl-code">请求数据包中的相应数据填入<span class="php-hl-identifier">php<span class="php-hl-code">:<span class="php-hl-comment">//<span class="php-hl-comment">input,否则其它情况都会。填入的长度,由Coentent-Length指定。 
 <span class="php-hl-number">4<span class="php-hl-code">,只有<span class="php-hl-identifier">Content<span class="php-hl-code">-<span class="php-hl-identifier">Type<span class="php-hl-code">为<span class="php-hl-identifier">application<span class="php-hl-code">/<span class="php-hl-identifier">x<span class="php-hl-code">-<span class="php-hl-identifier">www<span class="php-hl-code">-<span class="php-hl-identifier">data<span class="php-hl-code">-<span class="php-hl-identifier">urlencoded<span class="php-hl-code">时,<span class="php-hl-identifier">php<span class="php-hl-code">:<span class="php-hl-comment">//<span class="php-hl-comment">input数据才跟$_POST数据相一致。 
 <span class="php-hl-number">5<span class="php-hl-code">,<span class="php-hl-identifier">php<span class="php-hl-code">:<span class="php-hl-comment">//<span class="php-hl-comment">input数据总是跟$HTTP_RAW_POST_DATA相同,但是php://input比$HTTP_RAW_POST_DATA更凑效,且不需要特殊设置php.ini 
 <span class="php-hl-number">6<span class="php-hl-code">,<span class="php-hl-identifier">PHP<span class="php-hl-code">会将<span class="php-hl-identifier">PATH<span class="php-hl-code">字段的<span class="php-hl-identifier">query_path<span class="php-hl-code">部分,填入全局变量<span class="php-hl-var">$_GET<span class="php-hl-code">。通常情况下,<span class="php-hl-identifier">GET<span class="php-hl-code">方法提交的<span class="php-hl-identifier">http<span class="php-hl-code">请求,<span class="php-hl-identifier">body<span class="php-hl-code">为空。
 
例子
 <span class="php-hl-number">1<span class="php-hl-code">.<span class="php-hl-identifier">php<span class="php-hl-code">用<span class="php-hl-identifier">file_get_contents<span class="php-hl-brackets">(<span class="php-hl-quotes">"<span class="php-hl-string">php://input<span class="php-hl-quotes">"<span class="php-hl-brackets">)<span class="php-hl-code">或者<span class="php-hl-var">$HTTP_RAW_POST_DATA<span class="php-hl-code">可以接收<span class="php-hl-identifier">xml<span class="php-hl-code">数据
 比如:
  <span class="php-hl-identifier">getXML<span class="php-hl-code">.<span class="php-hl-identifier">php<span class="php-hl-code">;<span class="php-hl-comment">//<span class="php-hl-comment">接收XML地址<span class="php-hl-code">
  
<?<span class="php-hl-identifier">php 
     <span class="php-hl-var">$xmldata<span class="php-hl-code"> = <span class="php-hl-identifier">file_get_contents<span class="php-hl-brackets">(<span class="php-hl-quotes">"<span class="php-hl-string">php://input<span class="php-hl-quotes">"<span class="php-hl-brackets">)<span class="php-hl-code">; 
     <span class="php-hl-var">$data<span class="php-hl-code"> = <span class="php-hl-brackets">(<span class="php-hl-reserved">array<span class="php-hl-brackets">)<span class="php-hl-identifier">simplexml_load_string<span class="php-hl-brackets">(<span class="php-hl-var">$xmldata<span class="php-hl-brackets">)<span class="php-hl-code">; 
<span class="php-hl-inlinetags">?><span class="php-hl-code"> 
 
  这里的<span class="php-hl-var">$<span id="8_nwp">data<span class="php-hl-code">就是包含<span class="php-hl-identifier"><span id="7_nwp">xml<span class="php-hl-code">数据的数组,具体<span class="php-hl-identifier">php<span class="php-hl-code">解析<span class="php-hl-identifier">xml<span class="php-hl-code">数据更新详细的方法
  <span class="php-hl-identifier">sendXML<span class="php-hl-code">.<span class="php-hl-identifier">php<span class="php-hl-code">
 
<?<span class="php-hl-identifier">php 
     <span class="php-hl-var">$xml<span class="php-hl-code"> = <span class="php-hl-quotes">'<span class="php-hl-string"><xml>xmldata</xml><span class="php-hl-quotes">'<span class="php-hl-code">;<span class="php-hl-comment">//<span class="php-hl-comment">要发送的xml 
     <span class="php-hl-var">$url<span class="php-hl-code"> = <span class="php-hl-quotes">'<span class="php-hl-string">http://localhost/test/getXML.php<span class="php-hl-quotes">'<span class="php-hl-code">;<span class="php-hl-comment">//<span class="php-hl-comment">接收XML地址 
 
     <span class="php-hl-var">$header<span class="php-hl-code"> = <span class="php-hl-quotes">'<span class="php-hl-string">Content-type: text/xml<span class="php-hl-quotes">'<span class="php-hl-code">;<span class="php-hl-comment">//<span class="php-hl-comment">定义content-type为xml 
     <span class="php-hl-var">$ch<span class="php-hl-code"> = <span class="php-hl-identifier">curl_init<span class="php-hl-brackets">(<span class="php-hl-brackets">)<span class="php-hl-code">; <span class="php-hl-comment">//<span class="php-hl-comment">初始化curl 
     <span class="php-hl-identifier">curl_setopt<span class="php-hl-brackets">(<span class="php-hl-var">$ch<span class="php-hl-code">, <span class="php-hl-identifier">CURLOPT_URL<span class="php-hl-code">, <span class="php-hl-var">$url<span class="php-hl-brackets">)<span class="php-hl-code">;<span class="php-hl-comment">//<span class="php-hl-comment">设置链接 
     <span class="php-hl-identifier">curl_setopt<span class="php-hl-brackets">(<span class="php-hl-var">$ch<span class="php-hl-code">, <span class="php-hl-identifier">CURLOPT_RETURNTRANSFER<span class="php-hl-code">, <span class="php-hl-number">1<span class="php-hl-brackets">)<span class="php-hl-code">;<span class="php-hl-comment">//<span class="php-hl-comment">设置是否返回信息 
     <span class="php-hl-identifier">curl_setopt<span class="php-hl-brackets">(<span class="php-hl-var">$ch<span class="php-hl-code">, <span class="php-hl-identifier">CURLOPT_HTTPHEADER<span class="php-hl-code">, <span class="php-hl-var">$header<span class="php-hl-brackets">)<span class="php-hl-code">;<span class="php-hl-comment">//<span class="php-hl-comment">设置HTTP头 
     <span class="php-hl-identifier">curl_setopt<span class="php-hl-brackets">(<span class="php-hl-var">$ch<span class="php-hl-code">, <span class="php-hl-identifier">CURLOPT_POST<span class="php-hl-code">, <span class="php-hl-number">1<span class="php-hl-brackets">)<span class="php-hl-code">;<span class="php-hl-comment">//<span class="php-hl-comment">设置为POST方式 
     <span class="php-hl-identifier">curl_setopt<span class="php-hl-brackets">(<span class="php-hl-var">$ch<span class="php-hl-code">, <span class="php-hl-identifier">CURLOPT_POSTFIELDS<span class="php-hl-code">, <span class="php-hl-var">$<span id="6_nwp">xml<span class="php-hl-brackets">)<span class="php-hl-code">;<span class="php-hl-comment">//<span class="php-hl-comment">POST数据 
     <span class="php-hl-var">$response<span class="php-hl-code"> = <span class="php-hl-identifier">curl_exec<span class="php-hl-brackets">(<span class="php-hl-var">$ch<span class="php-hl-brackets">)<span class="php-hl-code">;<span class="php-hl-comment">//<span class="php-hl-comment">接收返回信息 
     <span class="php-hl-reserved">if<span class="php-hl-brackets">(<span class="php-hl-identifier">curl_errno<span class="php-hl-brackets">(<span class="php-hl-var">$ch<span class="php-hl-brackets">)<span class="php-hl-brackets">)<span class="php-hl-brackets">{<span class="php-hl-comment">//<span class="php-hl-comment">出错则显示错误信息 
     <span class="php-hl-identifier">print <span class="php-hl-identifier">curl_error<span class="php-hl-brackets">(<span class="php-hl-var">$ch<span class="php-hl-brackets">)<span class="php-hl-code">; 
     <span class="php-hl-brackets">} 
     <span class="php-hl-identifier">curl_close<span class="php-hl-brackets">(<span class="php-hl-var">$ch<span class="php-hl-brackets">)<span class="php-hl-code">; <span class="php-hl-comment">//<span class="php-hl-comment">关闭curl链接 
     <span class="php-hl-reserved">echo <span class="php-hl-var">$response<span class="php-hl-code">;<span class="php-hl-comment">//<span class="php-hl-comment">显示返回信息 
<span class="php-hl-inlinetags">?> 
 
 <span class="php-hl-number">2<span class="php-hl-code">.一个手机上传图片到服务器的小程序
  上传文件
   
<?<span class="php-hl-identifier">php 
     <span class="php-hl-comment">//<span class="php-hl-comment">@file phpinput_post.php 
     <span class="php-hl-var">$data<span class="php-hl-code">=<span class="php-hl-identifier">file_get_contents<span class="php-hl-brackets">(<span class="php-hl-quotes">'<span class="php-hl-string">btn.png<span class="php-hl-quotes">'<span class="php-hl-brackets">)<span class="php-hl-code">; 
     <span class="php-hl-var">$http_entity_body<span class="php-hl-code"> = <span class="php-hl-var">$<span id="5_nwp">data<span class="php-hl-code">; 
     <span class="php-hl-var">$http_entity_type<span class="php-hl-code"> = <span class="php-hl-quotes">'<span class="php-hl-string">application/x-www-form-urlencoded<span class="php-hl-quotes">'<span class="php-hl-code">; 
     <span class="php-hl-var">$http_entity_length<span class="php-hl-code"> = <span class="php-hl-identifier">strlen<span class="php-hl-brackets">(<span class="php-hl-var">$http_entity_body<span class="php-hl-brackets">)<span class="php-hl-code">; 
     <span class="php-hl-var">$host<span class="php-hl-code"> = <span class="php-hl-quotes">'<span class="php-hl-string">127.0.0.1<span class="php-hl-quotes">'<span class="php-hl-code">; 
     <span class="php-hl-var">$port<span class="php-hl-code"> = <span class="php-hl-number">80<span class="php-hl-code">; 
     <span class="php-hl-var">$path<span class="php-hl-code"> = <span class="php-hl-quotes">'<span class="php-hl-string">/image.<span id="4_nwp">php<span class="php-hl-quotes">'<span class="php-hl-code">; 
     <span class="php-hl-var">$fp<span class="php-hl-code"> = <span class="php-hl-identifier">fsockopen<span class="php-hl-brackets">(<span class="php-hl-var">$host<span class="php-hl-code">, <span class="php-hl-var">$port<span class="php-hl-code">, <span class="php-hl-var">$error_no<span class="php-hl-code">, <span class="php-hl-var">$error_desc<span class="php-hl-code">, <span class="php-hl-number">30<span class="php-hl-brackets">)<span class="php-hl-code">; 
     <span class="php-hl-reserved">if <span class="php-hl-brackets">(<span class="php-hl-var">$fp<span class="php-hl-brackets">)<span class="php-hl-brackets">{ 
        <span class="php-hl-identifier">fputs<span class="php-hl-brackets">(<span class="php-hl-var">$fp<span class="php-hl-code">, <span class="php-hl-quotes">"<span class="php-hl-string">POST <span class="php-hl-var">{$path}<span class="php-hl-string"> HTTP/1.1<span class="php-hl-special">\r<span class="php-hl-special">\n<span class="php-hl-quotes">"<span class="php-hl-brackets">)<span class="php-hl-code">; 
        <span class="php-hl-identifier">fputs<span class="php-hl-brackets">(<span class="php-hl-var">$fp<span class="php-hl-code">, <span class="php-hl-quotes">"<span class="php-hl-string">Host: <span class="php-hl-var">{$host}<span class="php-hl-special">\r<span class="php-hl-special">\n<span class="php-hl-quotes">"<span class="php-hl-brackets">)<span class="php-hl-code">; 
        <span class="php-hl-identifier">fputs<span class="php-hl-brackets">(<span class="php-hl-var">$fp<span class="php-hl-code">, <span class="php-hl-quotes">"<span class="php-hl-string">Content-Type: <span class="php-hl-var">{$http_entity_type}<span class="php-hl-special">\r<span class="php-hl-special">\n<span class="php-hl-quotes">"<span class="php-hl-brackets">)<span class="php-hl-code">; 
        <span class="php-hl-identifier">fputs<span class="php-hl-brackets">(<span class="php-hl-var">$fp<span class="php-hl-code">, <span class="php-hl-quotes">"<span class="php-hl-string">Content-Length: <span class="php-hl-var">{$http_entity_length}<span class="php-hl-special">\r<span class="php-hl-special">\n<span class="php-hl-quotes">"<span class="php-hl-brackets">)<span class="php-hl-code">; 
        <span class="php-hl-identifier">fputs<span class="php-hl-brackets">(<span class="php-hl-var">$fp<span class="php-hl-code">, <span class="php-hl-quotes">"<span class="php-hl-string">Connection: close<span class="php-hl-special">\r<span class="php-hl-special">\n<span class="php-hl-special">\r<span class="php-hl-special">\n<span class="php-hl-quotes">"<span class="php-hl-brackets">)<span class="php-hl-code">; 
        <span class="php-hl-identifier">fputs<span class="php-hl-brackets">(<span class="php-hl-var">$fp<span class="php-hl-code">, <span class="php-hl-var">$http_entity_body<span class="php-hl-code"> . <span class="php-hl-quotes">"<span class="php-hl-special">\r<span class="php-hl-special">\n<span class="php-hl-special">\r<span class="php-hl-special">\n<span class="php-hl-quotes">"<span class="php-hl-brackets">)<span class="php-hl-code">; 
 
        <span class="php-hl-reserved">while <span class="php-hl-brackets">(<span class="php-hl-code">!<span class="php-hl-identifier">feof<span class="php-hl-brackets">(<span class="php-hl-var">$fp<span class="php-hl-brackets">)<span class="php-hl-brackets">) <span class="php-hl-brackets">{ 
         <span class="php-hl-var">$d<span class="php-hl-code"> .= <span class="php-hl-identifier">fgets<span class="php-hl-brackets">(<span class="php-hl-var">$fp<span class="php-hl-code">, <span class="php-hl-number">4096<span class="php-hl-brackets">)<span class="php-hl-code">; 
        <span class="php-hl-brackets">} 
        <span class="php-hl-identifier">fclose<span class="php-hl-brackets">(<span class="php-hl-var">$fp<span class="php-hl-brackets">)<span class="php-hl-code">; 
        <span class="php-hl-reserved">echo <span class="php-hl-var">$d<span class="php-hl-code">; 
     <span class="php-hl-brackets">} 
<span class="php-hl-inlinetags">?><span class="php-hl-code"> 
 
  接收文件
  
<?<span class="php-hl-identifier">php 
        <span class="php-hl-comment">/*<span class="php-hl-comment">* 
         *Recieve image <span id="3_nwp">data 
        *<span class="php-hl-comment">*/    
        <span class="php-hl-identifier">error_reporting<span class="php-hl-brackets">(<span class="php-hl-identifier">E_ALL<span class="php-hl-brackets">)<span class="php-hl-code">; 
 
     <span class="php-hl-reserved">function <span class="php-hl-identifier">get_contents<span class="php-hl-brackets">(<span class="php-hl-brackets">) <span class="php-hl-brackets">{    
        <span class="php-hl-var">$xmlstr<span class="php-hl-code">= <span class="php-hl-identifier">file_get_contents</span><span class="php-hl-brackets">(</span><span class="php-hl-quotes">"php</span><span id="2_nwp">://input</span><span class="php-hl-quotes">"</span><span class="php-hl-brackets">)</span><span class="php-hl-code">; 
        </span><span class="php-hl-var">$filename</span><span class="php-hl-code">=</span><span class="php-hl-identifier">time</span><span class="php-hl-brackets">(</span><span class="php-hl-brackets">)</span><span class="php-hl-code">.</span><span class="php-hl-quotes">'</span><span class="php-hl-string">.png</span><span class="php-hl-quotes">'</span><span class="php-hl-code">; 
        </span><span class="php-hl-reserved">if</span><span class="php-hl-brackets">(</span>file_put_contents<span class="php-hl-brackets">(</span><span class="php-hl-var">$filename</span><span class="php-hl-code">,</span><span class="php-hl-var">$</span><span id="1_nwp">str</span>xml<span class="php-hl-brackets">)</span><span class="php-hl-brackets">)</span><span class="php-hl-brackets">{ 
         </span><span class="php-hl-reserved">echo </span><span class="php-hl-quotes">'</span><span class="php-hl-string">success</span><span class="php-hl-quotes">'</span><span class="php-hl-code">; 
        </span><span class="php-hl-brackets">}</span><span class="php-hl-reserved">else</span><span class="php-hl-brackets">{ 
         </span><span class="php-hl-reserved">echo </span><span class="php-hl-quotes">'</span><span class="php-hl-string">failed</span><span class="php-hl-quotes">'</span><span class="php-hl-code">; 
        </span><span class="php-hl-brackets">} 
        </span><span class="php-hl-brackets">} 
        </span><span class="php-hl-identifier">get_contents</span><span class="php-hl-brackets">(</span><span class="php-hl-brackets">)</span><span class="php-hl-code">; 
</span><span class="php-hl-inlinetags">?>
 </span><span class="php-hl-number">3</span><span class="php-hl-code">.获取</span><span class="php-hl-identifier">HTTP</span><span class="php-hl-code">请求原文
  
</span><span class="php-hl-comment">/*</span><span class="php-hl-comment">* 
     * 获取HTTP请求原文 
     *</span><span class="php-hl-inlinedoc"> @return </span><span class="php-hl-comment">string 
     </span><span class="php-hl-comment">*/ 
    </span><span class="php-hl-reserved">function </span><span class="php-hl-identifier">get_http_raw</span><span class="php-hl-brackets">(</span><span class="php-hl-brackets">) </span><span class="php-hl-brackets">{ 
     </span><span class="php-hl-var">$raw</span><span class="php-hl-code"> = </span><span class="php-hl-quotes">'</span><span class="php-hl-quotes">'</span><span class="php-hl-code">; 
 
     </span><span class="php-hl-comment">//</span><span class="php-hl-comment"> (1) 请求行 
     </span><span class="php-hl-var">$raw</span><span class="php-hl-code"> .= </span><span class="php-hl-var">$_SERVER</span><span class="php-hl-brackets">[</span><span class="php-hl-quotes">'</span><span class="php-hl-string">REQUEST_METHOD</span><span class="php-hl-quotes">'</span><span class="php-hl-brackets">]</span><span class="php-hl-code">.</span><span class="php-hl-quotes">' </span><span class="php-hl-quotes">'</span><span class="php-hl-code">.</span><span class="php-hl-var">$_SERVER</span><span class="php-hl-brackets">[</span><span class="php-hl-quotes">'</span><span class="php-hl-string">REQUEST_URI</span><span class="php-hl-quotes">'</span><span class="php-hl-brackets">]</span><span class="php-hl-code">.</span><span class="php-hl-quotes">' </span><span class="php-hl-quotes">'</span><span class="php-hl-code">.</span><span class="php-hl-var">$_SERVER</span><span class="php-hl-brackets">[</span><span class="php-hl-quotes">'</span><span class="php-hl-string">SERVER_PROTOCOL</span><span class="php-hl-quotes">'</span><span class="php-hl-brackets">]</span><span class="php-hl-code">.</span><span class="php-hl-quotes">"</span><span class="php-hl-special">\r</span><span class="php-hl-special">\n</span><span class="php-hl-quotes">"</span><span class="php-hl-code">; 
 
     </span><span class="php-hl-comment">//</span><span class="php-hl-comment"> (2) 请求Headers 
     </span><span class="php-hl-reserved">foreach</span><span class="php-hl-brackets">(</span><span class="php-hl-var">$_SERVER </span><span class="php-hl-reserved">as </span><span class="php-hl-var">$key</span><span class="php-hl-code"> => </span><span class="php-hl-var">$value</span><span class="php-hl-brackets">) </span><span class="php-hl-brackets">{ 
        </span><span class="php-hl-reserved">if</span><span class="php-hl-brackets">(</span><span class="php-hl-identifier">substr</span><span class="php-hl-brackets">(</span><span class="php-hl-var">$key</span><span class="php-hl-code">, </span><span class="php-hl-number">0</span><span class="php-hl-code">, </span><span class="php-hl-number">5</span><span class="php-hl-brackets">)</span><span class="php-hl-code"> === </span><span class="php-hl-quotes">'</span><span class="php-hl-string">HTTP_</span><span class="php-hl-quotes">'</span><span class="php-hl-brackets">) </span><span class="php-hl-brackets">{ 
         </span><span class="php-hl-var">$key</span><span class="php-hl-code"> = </span><span class="php-hl-identifier">substr</span><span class="php-hl-brackets">(</span><span class="php-hl-var">$key</span><span class="php-hl-code">, </span><span class="php-hl-number">5</span><span class="php-hl-brackets">)</span><span class="php-hl-code">; 
         </span><span class="php-hl-var">$key</span><span class="php-hl-code"> = </span><span class="php-hl-identifier">str_replace</span><span class="php-hl-brackets">(</span><span class="php-hl-quotes">'</span><span class="php-hl-string">_</span><span class="php-hl-quotes">'</span><span class="php-hl-code">, </span><span class="php-hl-quotes">'</span><span class="php-hl-string">-</span><span class="php-hl-quotes">'</span><span class="php-hl-code">, </span><span class="php-hl-var">$key</span><span class="php-hl-brackets">)</span><span class="php-hl-code">; 
 
         </span><span class="php-hl-var">$raw</span><span class="php-hl-code"> .= </span><span class="php-hl-var">$key</span><span class="php-hl-code">.</span><span class="php-hl-quotes">'</span><span class="php-hl-string">: </span><span class="php-hl-quotes">'</span><span class="php-hl-code">.</span><span class="php-hl-var">$value</span><span class="php-hl-code">.</span><span class="php-hl-quotes">"</span><span class="php-hl-special">\r</span><span class="php-hl-special">\n</span><span class="php-hl-quotes">"</span><span class="php-hl-code">; 
        </span><span class="php-hl-brackets">} 
     </span><span class="php-hl-brackets">} 
 
     </span><span class="php-hl-comment">//</span><span class="php-hl-comment"> (3) 空行 
     </span><span class="php-hl-var">$raw</span><span class="php-hl-code"> .= </span><span class="php-hl-quotes">"</span><span class="php-hl-special">\r</span><span class="php-hl-special">\n</span><span class="php-hl-quotes">"</span><span class="php-hl-code">; 
 
     </span><span class="php-hl-comment">//</span><span class="php-hl-comment"> (4) 请求Body 
     </span><span class="php-hl-var">$raw</span><span class="php-hl-code"> .= </span><span class="php-hl-identifier">file_get_contents</span><span class="php-hl-brackets">(</span><span class="php-hl-quotes">'php</span><span id="0_nwp">://input</span><span class="php-hl-quotes">'</span><span class="php-hl-brackets">)</span><span class="php-hl-code">; 
 
     </span><span class="php-hl-reserved">return </span><span class="php-hl-var">$raw</span><span class="php-hl-code">; 
</span><span class="php-hl-brackets">}</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
Copier après la connexion
Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Recommandations populaires
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal