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 above label is in www.jb51.net
$ Tags = get_meta_tags ('http: // www.jb51.net ');
// Note that all keys are in lowercase, and '.' in the key is converted '_'.
Echo $ tags ['author']; // dxy | www.jb51.net
Echo $ tags ['keyword']; // script, vbscript, regular expression, jquery, dos, bat, batch processing, javascript, Photoshop, HTML, p + css, ASP, PHP, ASP. NET
Echo $ tags ['description']; // 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.