从PHP发布到ASP页面返回原始源代码
我试图将数据从PHP发布到ASP页面。这是PHP代码:从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',
$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服务器解析/执行此文件),您只是读取实际的文件内容。