$url = 'https://site';
copy('https://site', \Yii::getAlias('@webroot').'/scrapping.html');
$response=\common\models\helpers\Scrapping\SimpleHtmlDom::fileGetHtml(\Yii::getAlias('@webroot').'/scrapping.html');
var_dump($response);
exit();
我正在使用keltstr\simplehtmldom\ extension.
这里我正在做的是获取数据并将其存储在我的服务器上并从我自己的本地文件中删除。它在上面的php 7.0上执行无限循环但在php 7.0中工作正常。为什么这种情况发生在php版本中。?当我在此函数中直接使用url时出现相同的错误
// $response = \keltstr\simplehtmldom\SimpleHTMLDom::fileGetHtml($url);
这里基本上没有库中的问题
无限循环的问题就在于var_dump();
Here is the code
$response = file_get_html(url);
var_dump($response);
Here you will see the infinte loop in some server
所以请在没有var_dump()的情况下进行剩下的测试;代码中已有响应。
你需要在php 7下面关注一件事,你需要添加0作为偏移量
foreach ($response->find('article',0) as $article) {
上面的PHP 7代码将是
foreach ($response->find('article') as $article) {