如何知道 url 何时使用 php 中的 fopen 加载?

how to know when a url is loaded using fopen in php?

我这样调用 fopen:fopen($url.urlencode("\"-BENCHMARK(100000000, rand()) -- -"),"r");

但是不知道函数的return是什么时候追加的。 (我试着在之后放一个回声,它立即执行……也许 fopen 创建了一个子线程……),知道吗?

谢谢

来自 PHP 文档:

Returns a file pointer resource on success, or FALSE on error.

试试这个:

if (!$handle = fopen($url.urlencode("\"-BENCHMARK(100000000, rand()) ---"),"r"))
{
    echo "error";
} else {
   //do something with $handle
}

"how to know when a url is loaded using fopen in php?" -- 最有可能的是,fopen() returns as soon as the first data packet of the response is received. You have to fread() (or similar) from the resource returned by fopen() until feof() returns TRUE 找出响应何时完成。