すぐ出るエラー おそらくPHP7以上 の対応
Compile Error - Array and string offset access syntax with curly braces is no longer supported in APPPATH/vendor/phpQuery-onefile.php on line 2156
エラーの通りソースコードを修正
2156行と2171行のエラーを修正 {数値} を [数値] へ
修正前
// 2156行
if ($param{0} == 'n')
// 2171行
else if (mb_strlen($param) > 1 && $param{1} == 'n')
修正後
// 2156行
if ($param[0] == 'n')
// 2171行
else if (mb_strlen($param) > 1 && $param[1] == 'n')
この後に出るエラー
修正してもこういうエラーが出ます。
phpQuery-onefile.php(327): DOMDocument->loadHTML()
phpQuery-onefile.php(244): DOMDocumentWrapper->loadMarkupHTML()
phpQuery-onefile.php(191): DOMDocumentWrapper->loadMarkup()
phpQuery-onefile.php(177): DOMDocumentWrapper->load()
phpQuery-onefile.php(4857): DOMDocumentWrapper->__construct()
phpQuery-onefile.php(4631): phpQuery::createDocumentWrapper()
この対策はこう。 phpQuery::newDocumentの前後にこんな記述を入れます。
$url = "https://xxxx.com";
$html = file_get_contents($url);
libxml_use_internal_errors( true ); // 追加
$html = \phpQuery::newDocument($html);
libxml_clear_errors(); // 追加
これで phpQuery が利用できます。