array get_meta_tags(string $filename, bool $use_include_path = false)
<meta> 標籤直到 </head>。$filename 可為本地路徑或 URL。$use_include_path 為 true 時在 include_path 中查找本地文件。關聯數組:鍵為 name 屬性值(特殊字符轉 `_`,轉小寫),值為 content 屬性值。同名 name 取最後一個。
$tags = get_meta_tags('https://www.jb51.net');
echo $tags['author']; // dxy | www.jb51.net
echo $tags['keywords']; // 腳本,vbscript,正則表達式,jquery,...
echo $tags['description']; // 是國內專業的網站建設資源...
<meta name="author" content="name"> <meta name="keywords" content="php documentation"> <meta name="DESCRIPTION" content="a php manual"> <meta name="geo.position" content="49.33;-86.59"> </head> <!-- 解析停止 -->
name 屬性的 meta**,http-equiv、charset 等不解析。allow_url_fopen,且受網絡延遲影響。