Warning: require_once(/mnt/hgfs/www/open/test/Requests-master/library/Requests/Exception.php): failed to open stream: Too many open files in /mnt/hgfs/www/open/test/Requests-master/library/Requests.php on line 136PHP Fatal error: require_once(): Failed opening required '/mnt/hgfs/www/open/test/Requests-master/library/Requests/Exception.php' (include_path='.:/usr/local/php/lib/php') in /mnt/hgfs/www/open/test/Requests-master/library/Requests.php on line 136Fatal error: require_once(): Failed opening required '/mnt/hgfs/www/open/test/Requests-master/library/Requests/Exception.php' (include_path='.:/usr/local/php/lib/php') in /mnt/hgfs/www/open/test/Requests-master/library/Requests.php on line 136
// 從資料庫取出一篇文章include '../Requests-master/Request.php';$article_cond='some cond';$article=$db->fetchByCond($article_cond)while($article){ $return=Request::post($url,$data,$header); // do others $article=$db->fetchByCond($article_cond);}
下面的是出錯的這個檔案
public static function autoloader($class) { // Check that the class starts with "Requests" if (strpos($class, 'Requests') !== 0) { return; } $file = str_replace('_', '/', $class); if (file_exists(dirname(__FILE__) . '/' . $file . '.php')) { // 下面這行是136行 require_once(dirname(__FILE__) . '/' . $file . '.php'); } }
從資料庫取出文章,然後用PHP Requests這個庫將文章插入另一個伺服器上的資料庫(這裡都是127.0.0.1)。不知道什麼會出現這個問題,每插入1020篇文章就會出現這個問題,不知道是哪裡設定的問題呢?
回複內容:
Warning: require_once(/mnt/hgfs/www/open/test/Requests-master/library/Requests/Exception.php): failed to open stream: Too many open files in /mnt/hgfs/www/open/test/Requests-master/library/Requests.php on line 136PHP Fatal error: require_once(): Failed opening required '/mnt/hgfs/www/open/test/Requests-master/library/Requests/Exception.php' (include_path='.:/usr/local/php/lib/php') in /mnt/hgfs/www/open/test/Requests-master/library/Requests.php on line 136Fatal error: require_once(): Failed opening required '/mnt/hgfs/www/open/test/Requests-master/library/Requests/Exception.php' (include_path='.:/usr/local/php/lib/php') in /mnt/hgfs/www/open/test/Requests-master/library/Requests.php on line 136
// 從資料庫取出一篇文章include '../Requests-master/Request.php';$article_cond='some cond';$article=$db->fetchByCond($article_cond)while($article){ $return=Request::post($url,$data,$header); // do others $article=$db->fetchByCond($article_cond);}
下面的是出錯的這個檔案
public static function autoloader($class) { // Check that the class starts with "Requests" if (strpos($class, 'Requests') !== 0) { return; } $file = str_replace('_', '/', $class); if (file_exists(dirname(__FILE__) . '/' . $file . '.php')) { // 下面這行是136行 require_once(dirname(__FILE__) . '/' . $file . '.php'); } }
從資料庫取出文章,然後用PHP Requests這個庫將文章插入另一個伺服器上的資料庫(這裡都是127.0.0.1)。不知道什麼會出現這個問題,每插入1020篇文章就會出現這個問題,不知道是哪裡設定的問題呢?
Too many open files,這個提示說的很明白了,開發的檔案太多了。
一個進程開啟的檔案數目是有上限的,無法超過這個值,require_once是要開啟檔案的,所以就出錯了。
回到你的問題,單純require是不應該達到檔案開啟上限的,兩個方向來查問題吧
是否存在迴圈require的問題?
是否在其他位置open檔案太多並且沒有close?