get_meta_tags() parses the meta tag information from a file or URL. Parsing stops when the closing head tag</head>) is encountered.
Tag information is returned as an associative array. The keys of the array correspond to the name attributes of the meta tags, and the values of the array correspond to the content attributes. If the filename_or_url argument contains a relative filename and use_include_path is set to 1, PHP searches the include path for the file.
The function converts all of the key values to lowercase and replaces any period (.), backslash (\), plus+), asterisk (*), question mark?), bracket (), caret^), dollar sign ($), space ( ), and parenthesis (()) characters with the underscore_) character.
get_meta_tags() is not a robust function. In many situations, the function fails to retrieve all the meta tags from a document. See the following list of conditions.
If the values associated with the name or description attributes are not quoted, the meta tag is not parsed.
<meta name=foo content=bar> <!-- This tag will not be parsed properly -->
If the meta tag contains a newline, the meta tag is not parsed.
<meta name="foo" content="bar"> <!-- This tag will not be parsed properly -->
If a line contains more than one meta tag, the second and subsequent meta tags are not parsed.
<meta name="a" content="1"> <!-- Only the first tag is parsed --> <meta name="b" content="2">
Malformed meta tags may parse incorrectly.
<meta name="a" foo="bar" content="1"> <meta name="b" content="2"> <!-- If you parse this example using get_meta_tags(), b ends up containing the value for a -->
PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/). The authors of this book have elected not to choose any options under the OPL. This online book was obtained from http://www.fooassociates.com/phpfer/ and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.