![](/img/trans.png)
[英]php simple_html_dom load_file/file_get_contents timeout not working
[英]How do I tell PHP to get rid of load_file data after it's used?
這是我的PHP。 它通過一系列URL運行以獲取類似數據(來自棒球運動員資料的當前本壘打)。 但是,我得到的是“允許的內存大小用盡”,這使我認為PHP只是聚合了所有這些load_file數據,即使在我使用$ html-> find來獲取所需數據之后也是如此。 我已經回顯了我的需要之后,如何告訴PHP停止使用來自load_file的數據?
include('simple_html_dom.php');
$json = file_get_contents("http://example.com/homeruns.json");
$elements = json_decode($json);
foreach ($elements as $element){
$html = new simple_html_dom();
$html->load_file($element->profileurl);
$currenthomeruns = $html->find('.homeruns .current',0);
echo $element->name, " currently has the following number of homeruns: ", strip_tags($currenthomeruns);
}
在循環結束時,執行unset($ html);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.