我有这段代码:
$target_url = "http://mysiteexmpl.com/";
$html = new simple_html_dom();
$html->load_file($target_url);
//here I find specific links and start looping each
foreach($html->find('a.link') as $link){
$newtarget_url = $link->href;
//here I open each url that I find as new
$newhtml = new simple_html_dom();
$newhtml->load_file($newtarget_url);
//getting price
foreach($newhtml->find('div.pprice') as $price){
$price=preg_replace("/[^0-9.]/", "",$price);echo '<br>';
}
//getting other info and so on
foreach($newhtml->find('div.prohead > h1') as $title){
$title= $title->innertext;echo '<br>';
}
//here I execute several queries and copying images from remote site to mine
}
问题是我的目标url-s是21,如果我回显$ newtarget_url并且不执行查询,但是当执行完整代码并且查询循环停止在第7个url并且不要遍历所有21个url-s它应该循环 这是内存泄漏问题还是其他问题?怎么调试呢?如何优化上面的代码?
感谢你的时间