gpt4 book ai didi

php - 通过 "preg_match_all"函数特殊字符获取html内容时显示不正常,如何解决?

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:41:44 24 4
gpt4 key购买 nike

我正在使用下面的代码获取 html 内容,

preg_match_all('/<div class="content">(.*?)<\/div>/s', $str, $matches);
echo $matches[1][0];

内容已正确获取,但一些特殊字符和文本无法正常显示

“response to what?”显示为“response to what?”

but it doesn't 显示为但没关系。一些空白显示为

如何解决这个问题..?

最佳答案

您有 unicode 问题,请尝试将其添加为脚本的第一行:

header('Content-Type: text/html; charset=utf-8');

关于php - 通过 "preg_match_all"函数特殊字符获取html内容时显示不正常,如何解决?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15679242/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com