我該如何讓這個腳本可以使用多線程? 已經嘗試過所有的教程,但沒有成功:( ,什麼是最大的線程數,我可以捲曲的PHP使用?如何使用多線程的php curl?
<?php $imput = file("$argv[1]"); $output = $argv[2]; foreach ($imput as $nr => $line) { $line = trim($line); print ("$nr - check :" . $line . "\r\n"); $check = ia_continutul($line); if (strpos($check,'wordpress') !== false) { $SaveFile = fopen($output, "a"); fwrite($SaveFile, "$line\r\n"); fclose($SaveFile); } } print "The END !\r\n"; function ia_continutul($url) { $ch = curl_init(); $timeout = 3; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); curl_setopt($ch, CURLOPT_TIMEOUT, 5); $data = curl_exec($ch); curl_close($ch); return $data; } ?>
http://php.net/manual/en/function.curl-multi-exec.php –
PHP不是多線程的,並且很可能永遠不會對語言進行根本性的重新設計。 –