You may not know the PHP get_meta_tags() function_PHP Tutorial

WBOY
Release: 2016-07-13 10:29:48
Original
813 people have browsed it

Definition and usage:

get_meta_tags — Extract all meta tag content attributes from a file and return an array

Grammar:

Copy code The code is as follows:
array get_meta_tags(string filename, int [use_include_path]);
#Open filename and parse line by line tags in files. Parsing will stop at .

参数 描述
filename

HTML 文件的路径字符串

此参数可以是本地文件也可以是一个 URL。

Example #1 get_meta_tags() 解析了什么

(注意回车换行 - PHP 使用一个本地函数来解析输入,所以 Mac 上的文件将不能在 Unix 上正常工作)。

use_include_path 将 use_include_path 设置为 TRUE 将使 PHP 尝试按照 include_path 标准包含路径中的每个指向去打开文件。这只用于本地文件,不适用于 URL。
Parameters

Description
filename Path string of HTML file


This parameter can be a local file or a URL.

Example #1 What does get_meta_tags() parse


(Note the carriage return and line feed - PHP uses a native function to parse the input, so files on Mac will not work properly on Unix).
use_include_path Setting use_include_path to TRUE will cause PHP to try to open files at every point in include_path's standard include path. This only works with local files, not URLs.

Return value


Returns an array containing all parsed meta tags. The returned associative array has the value of the name attribute as the key and the value of the content attribute as the value, so you can easily iterate over this associative array or access a value using standard array functions. Special characters in the attribute name will be replaced with '_', while other characters will be converted to lowercase. If there are two meta tags with the same name, only the last one that appears is returned.

Example

Copy code

// Assume that the above tag is in www.jb51.net $ tags = get_meta_tags('http://www.jb51.net'); // Note that all keys are in lowercase, and the ‘.’ in the key is converted to ‘_’. echo $tags['author']; // dxy | www.jb51.netecho $tags['keywords']; // Script, vbscript, regular expression, jquery, dos, bat, batch Processing, javascript, Photoshop, HTML, div+css, ASP, PHP, ASP.NETecho $tags['description']; // Script House is a domestic professional website construction resource and script programming learning website. Provides programming materials such as asp, php, asp.net, javascript, jquery, vbscript, dos batch processing, web page production, network programming, website construction, etc.
Special Instructions
Only meta tags containing the name attribute will be parsed. http://www.bkjia.com/PHPjc/769244.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/769244.htmlTechArticleDefinition and usage: get_meta_tags — Extract all meta tag content attributes from a file and return an array Syntax: Copy The code is as follows: array get_meta_tags(string f...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template