0

Functionは下記の通りにですが

function pageContent(String $url): \DOMDocument
        {
            $html = cache()->rememberForever($url, function () use ($url) {
                return file_get_contents($url);
            });
            $parser = new \DOMDocument();
            libxml_use_internal_errors(true);

            $parser->loadHTML($html = mb_convert_encoding($html, "SJIS", "UTF-8"));

            return $parser;
        }

Functionにmb_convert_encoding($html, "SJIS", "UTF-8")入れましたがこちらのウエッブサイトでデータが読めません。ターミナルに何も表示できません。原因は何でしょうか

1 件の回答 1

1

これを試して:

$parser->loadHTML(mb_convert_encoding($html, "SJIS", "UTF-8"));

または:

echo mb_detect_encoding($html); // ???

この質問に回答するには、ログインする必要があります。

求めていた回答ではありませんか? のタグが付いた他の質問を参照する。