【发布时间】:2014-06-22 15:19:17
【问题描述】:
我使用 PHP 和 file_get_contents。即使我试图用这个来加速它也真的很慢:
$opts = array(
'http'=> array(
'header' => 'Connection: close'
)
);
$context = stream_context_create($opts);
$contents = file_get_contents('http://www.example.com/file.txt', false, $context);
我也试过cURL。同样的问题。
我读到include 应该比file_get_contents 慢。这似乎只在不包括整个 URL 但包括相对路径时才成立,就像这样......
file_get_contents('../file.txt');
我的问题是……为什么相对路径比完整 URL 快得多?
【问题讨论】:
-
也许第二个使用本地文件系统,而不是 http?
标签: php url path file-get-contents