Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 不工作:使用文件获取内容发布数据_Php - Fatal编程技术网

Php 不工作:使用文件获取内容发布数据

Php 不工作:使用文件获取内容发布数据,php,Php,我正在学习,我正在尝试将数据发布到4.php,并将结果打印到range.php上。。我已经看过了 我想知道为什么它不打印任何东西。。。请帮助我。我已使用PHP手册中的代码更新了您的代码,并进行了一些更改,如将PHP标记添加到4.PHP以及修复$\u请求中的打字错误 以下是更新后的代码,似乎对我有用: <?php $data = array ('foo' => 'bar', 'bar' => 'baz'); $data = http_build_query($data); $

我正在学习,我正在尝试将数据发布到4.php,并将结果打印到range.php上。。我已经看过了


我想知道为什么它不打印任何东西。。。请帮助我。

我已使用PHP手册中的代码更新了您的代码,并进行了一些更改,如将PHP标记添加到4.PHP以及修复
$\u请求中的打字错误

以下是更新后的代码,似乎对我有用:

<?php

$data = array ('foo' => 'bar', 'bar' => 'baz');
$data = http_build_query($data);

$context_options = array (
        'http' => array (
            'method' => 'POST',
            'header'=> "Content-type: application/x-www-form-urlencoded\r\n"
                . "Content-Length: " . strlen($data) . "\r\n",
            'content' => $data
            )
        );

$context = stream_context_create($context_options);
 $result = file_get_contents('http://localhost/php/4.php', false, $context);
 var_dump($result);//prints something :)
?>

我已使用PHP手册中的代码更新了您的代码,并进行了一些更改,如将PHP标记添加到4.PHP,以及修复
$\u请求中的打字错误

以下是更新后的代码,似乎对我有用:

<?php

$data = array ('foo' => 'bar', 'bar' => 'baz');
$data = http_build_query($data);

$context_options = array (
        'http' => array (
            'method' => 'POST',
            'header'=> "Content-type: application/x-www-form-urlencoded\r\n"
                . "Content-Length: " . strlen($data) . "\r\n",
            'content' => $data
            )
        );

$context = stream_context_create($context_options);
 $result = file_get_contents('http://localhost/php/4.php', false, $context);
 var_dump($result);//prints something :)
?>

4.php中的$result来自哪里?没有看到它被定义或声明anywhere@codisfy编辑代码bro,4.php中的$result来自哪里?没有看到它被定义或声明anywhere@codisfy在我的打印中编辑了代码bro,string(6043)”\r在我的打印中显示此字符串(6043)“string(6043)”\r在我的打印中显示此字符串(6043)”
<?php

$data = array ('foo' => 'bar', 'bar' => 'baz');
$data = http_build_query($data);

$context_options = array (
        'http' => array (
            'method' => 'POST',
            'header'=> "Content-type: application/x-www-form-urlencoded\r\n"
                . "Content-Length: " . strlen($data) . "\r\n",
            'content' => $data
            )
        );

$context = stream_context_create($context_options);
 $result = file_get_contents('http://localhost/php/4.php', false, $context);
 var_dump($result);//prints something :)
?>
<?php

 print_r($_REQUEST);
$postdata = http_build_query($_POST);
print_r($postdata);