PHP是否有任何本地工具来打开像http://example.com/a.rb?A=4
这样的页面,然后将响应作为文本?
你可以使用file_get_contents(),但我认为curl是最好的方法。
这是一个很好的PHP类你必须知道http://simplehtmldom.sourceforge.net/
正如其他人提到的,您可以使用:
$var = file_get_contents("http://google.com");
或者你可以使用curl:
<?php
// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, "example.com");
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$output = curl_exec($ch);
// close curl resource to free up system resources
curl_close($ch);
?>
我复制了curl的例子:http://www.php.net/manual/en/curl.examples.php