Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.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发布到ASP页面返回原始源代码_Php_Post_Asp Classic - Fatal编程技术网

从PHP发布到ASP页面返回原始源代码

从PHP发布到ASP页面返回原始源代码,php,post,asp-classic,Php,Post,Asp Classic,我试图将数据从PHP发布到ASP页面。这是PHP代码: $url = 'test.asp'; $data = array('q' => 'test'); $options = array( 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST',

我试图将数据从PHP发布到ASP页面。这是PHP代码:

$url = 'test.asp';
$data = array('q' => 'test');

$options = array(
    'http' => array(
        'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
        'method'  => 'POST',
        'content' => http_build_query($data)
    )
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) { 
  //Handle error
 }

var_dump($result);
这是ASP页面:

<%Response.Write(request("q"))%>


当我调用PHP页面时,它会打印
。我正在安装了经典Asp和Php的IIS上测试此结构。

test.Asp
在某些上下文中是一个相对URL,它不在这里

file\u get\u contents
仅当您传递一个绝对URL(例如,以
开头的URL)时才会发出HTTP请求http://www.example.com/

向其传递文件名将使其从本地文件系统读取,而本地文件系统将绕过任何将执行ASP代码的HTTP服务器模块。

“$url='test.ASP';”-这是本地文件系统路径,而不是HTTP url。您没有发出HTTP请求(这将使web服务器解析/执行此文件),您只是读取实际的文件内容。