我从curl_multi_*条目的PHP手册中获取了以下代码:
$active = null;
do {
$process = curl_multi_exec($curl, $active);
} while ($process === CURLM_CALL_MULTI_PERFORM);
while (($active >= 1) && ($process === CURLM_OK))
{
if (curl_multi_select($curl, 3) != -1)
{
do {
$process = curl_multi_exec($curl, $active);
} while ($process === CURLM_CALL_MULTI_PERFORM);
}
}
Run Code Online (Sandbox Code Playgroud)
现在问题是我真的不喜欢写作...而循环和我想知道什么是最好和更短的方法来完成相同但没有使用这种循环.
到目前为止,我已经提出了一个稍长的版本,但我不确定它是否完全相同,或者它是否与原始版本的执行方式相同:
while (true)
{
$active = 1;
$process = curl_multi_exec($curl, $active);
if ($process === CURLM_OK)
{
while (($active >= 1) && (curl_multi_select($curl, 3) != -1))
{
$process = CURLM_CALL_MULTI_PERFORM;
while ($process === CURLM_CALL_MULTI_PERFORM)
{
$process = …Run Code Online (Sandbox Code Playgroud)