Home > Backend Development > PHP Tutorial > php get_meta_tags function_PHP tutorial

php get_meta_tags function_PHP tutorial

WBOY
Release: 2016-07-20 11:01:04
Original
1120 people have browsed it

php get_meta_tags function ​

get_meta_tags
(PHP 4, PHP 5)

get_meta_tags - Extracts all meta tag content attributes from a file and returns an array

Description
array get_meta_tags (string $filename[, boolean $use_include_path=false])
Open the file and parse its line-by-line

tagged files. Parse station "/header".

Parameters

File name
The path to the HTML file, as a string. This can be a local file or a URL.


Example #1 What get_meta_tags() parses





"/header" "! -parsing stops here -" (note the line ending - PHP uses the function parse local inputs, so files on Mac will not work properly on Unix).

use_include_path
Setting use_include_path to TRUE will cause PHP to attempt to open the file with the standard include: path along the path of the include_path directive. This is for local files, not URLs.


Return value
Returns an array of all parsed meta tags.

The value of the Name property becomes the key to the value of the value content of the property, returned in the array, so that you can easily use standard array functions to iterate over or access a single value. Special characters in the value property name are replaced with '_' and the rest will be converted to lowercase. If there are two meta tags with the same name, only the last one is returned.

Modify

Release Notes
4.0.5 supports the unquoted HTML attribute added.


Example

Example #2 What get_meta_tags() returns

// Assuming the above tags are at www.example.com
$tags = get_meta_tags('http://www.example.com/');

// Notice how the keys are all lowercase now, and
// how . was replaced by _ in the key.
echo $tags['author']; // name
echo $tags['keywords']; // php documentation
echo $tags['description']; // a php manual
echo $tags['geo_position']; // 49.33;-86.59
?>


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445459.htmlTechArticlephp get_meta_tags function get_meta_tags (PHP 4, PHP 5) get_meta_tags - Extract all meta tag content attributes from a file and returns an array describing the array get_meta_tags...
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