在PHP中读取原始I / O流的替代方法 [英] Alternative way to read raw I/O stream in PHP
问题描述
我试图找到一个替代阅读php://输入。我使用这个从CURL PUT获取XML数据。
我通常这样做:
$ xml = file_get_contents('php:// input');
然而,我遇到了一些与 是否有替代方案,可能使用 是的,您可以这样做: b 但是,您必须问自己的问题是为什么不是 I am trying to find an alternative to reading php://input. I use this for getting XML data from a CURL PUT. I usually do this with: However, I'm having a few issues with Is there an alternative, perhaps using Yes, you can do: But, the question you have to ask yourself is why isn't 这篇关于在PHP中读取原始I / O流的替代方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! file_get_contents()
fopen()
或 fread()
?
$ b
$ f = fopen('php:// input','r');
if(!$ f)die(Could not open input stream \\\
);
$ data ='';
while($ buffer = fread($ f,8192))$ data。= $ buffer;
fclose($ f);
file_get_contents
在Windows上工作?因为如果它不工作,我怀疑 fopen
可以用于同一个流... $xml = file_get_contents('php://input');
file_get_contents()
on Windows.fopen()
or fread()
?$f = fopen('php://input', 'r');
if (!$f) die("Couldn't open input stream\n");
$data = '';
while ($buffer = fread($f, 8192)) $data .= $buffer;
fclose($f);
file_get_contents
working on windows? Because if it's not working, I doubt fopen
would work for the same stream...