如何使用php获取URL标题编码来解决错误

时间:2019-01-01 06:32:19

标签: php encoding utf-8

我有下面的php代码,它给出了非拉丁字母的错误

header('Content-Type: text/html; charset=utf-8'); 
$u = $_GET['url'];
$urlContents = file_get_contents($u);
$dom = new DOMDocument();
 @$dom->loadHTML($urlContents);
$title = $dom->getElementsByTagName('title');
print($title->item(0)->nodeValue . "\n");        

0 个答案:

没有答案