PHP Simple HTML DOM Parserを使ってHTMLをパースしていたりしたのですが、さくらレンサバのPHPを7.2にあげたら動かなくなりました。。。
ということで調べてみると素敵な記事発見。
環境
PHP 7.2.0
PHP Simple HTML DOM Parser 1.5.2
現象
以下の結果はfalseになります。
test.php
<?php
require(__DIR__. "/v...
このようになってたソースを
$html = file_get_html($url);
以下に変えることで動きました。
$html = @file_get_contents($url); $html = str_get_html($html);
一安心。
2019/07/04:追記
さくらレンサバのPHPが強制的に7.3に上がったことにより、また動かなくなりました(涙
調べてみるとgithub上でディスカッションされてました。
PHP Warning 'yii\base\ErrorException' with message 'preg_match(): Compilation failed: invalid range in character class at offset 4' in .../sunra...
この中に新しいファイルをダウンロードする以下のページがあり、コレを使ったら無事動きました。
Download PHP Simple HTML DOM Parser for free. A php based DOM parser. A simple PHP HTML DOM parser written in PHP5+, supports invalid HTML, and provides a very ...
たまにしかやらない雑エンジニアは、こういうところに毎回ハマります。。。