如何从 <meta> 中检索信息?标记并将其显示在网页上? [英] How can I retrieve information from the <meta> tag and display it on a webpage?

查看:43
本文介绍了如何从 <meta> 中检索信息?标记并将其显示在网页上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,如果我有以下代码:

For example, if I have the following code:

<head>
    <meta name="description" content="Question">
    <meta name="keywords" content="StackExchange, Webmasters">
    <meta name="author" content="Jon Doe">
</head>

我需要在网页的某处显示以下内容:

I need the following to be displayed somewhere on the webpage:

  • 描述:问题
  • 关键字:StackExchange、网站管理员
  • 作者:Jon Doe
  • Description: Question
  • Keywords: StackExchange, Webmasters
  • Author: Jon Doe

我怎样才能做到这一点?

How could I achieve this?

推荐答案

在 PHP 中,您将首先使用 get_meta_tags() 获取元信息作为数组并将不同的元标记回显到任何地方希望它们显示在您的页面上.

In PHP, you would first grab the Meta information with get_meta_tags() as an array and echo the different meta tags to wherever you want them to be displayed on your page.

例如:

$metastealer = get_meta_tags('http://yourdomain.com');
echo $metastealer['description'];
echo $metastealer['keywords'];
echo $metastealer['author'];

更多信息这里这里,如果某些东西不太正常,可能此处.

More information here, here and if something doesn't quite work right probably here.

这篇关于如何从 &lt;meta&gt; 中检索信息?标记并将其显示在网页上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆