You may not know the PHPget_meta_tags () function

Source: Internet
Author: User
This article mainly introduces the PHPget_meta_tags () function that you may not know. it is a more practical function. this is also the first time that you can see it. For more information, see Definition and usage:

Get_meta_tags-extract all meta tag content attributes from a file and return an array

Syntax:

The code is as follows: array get_meta_tags (string filename, int [use_include_path]);
# Open filename to parse the file line by line Label. Resolution will be performed in.

Parameters Description
Filename

Path string of the HTML file

This parameter can be a local file or a URL.

Example #1 What does get_meta_tags () parse?

(Note: press enter to wrap the line-PHP uses a local function to parse the input, so files on Mac won't work normally on Unix ).

Use_include_path Setting use_include_path to TRUE will enable PHP to try to open the file according to each point in the include_path standard. This is only used for local files and does not apply to URLs.

Return value

Returns an array containing all parsed meta tags.
The returned joined array uses the value of attribute name as the key and the value of attribute content as the value, so you can easily use the standard array function to traverse the joined array or access a value. Special characters in the property name are replaced with '_', while other characters are converted to lowercase letters. If two meta tags have the same name, only the last one is returned.

Example

The code is as follows:
// Assume that the preceding tag is in www.bitsCN.com.
$ Tags = get_meta_tags ('http: // www.bitsCN.com ');

// Note that all keys are in lowercase, and '.' in the key is converted '_'.
Echo $ tags ['author']; // dxy | www.bitsCN.com
Echo $ tags ['keyword']; // script, vbscript, regular expression, jquery, dos, bat, batch processing, javascript, Photoshop, HTML, p + css, ASP, PHP, ASP. NET
Echo $ tags ['description']; // It is a professional website construction resource and script programming learning website in China, provides programming materials such as asp, php, asp.net, javascript, jquery, vbscript, dos batch processing, web page creation, network programming, and website construction.

Note

Only meta tags containing the name attribute are parsed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.