get_meta_tags
Extracts all meta tag content attributes from a file and returns an array.
get_meta_tags Function synopsis
get_meta_tags(string $filename, bool $use_include_path = false): array|false
Parameters
$filename
Typestring
The path to the HTML file, as a string. This can be a local file or an URL.
$use_include_path
OptionalTypeboolDefault valuefalse
Setting $use_include_path to true will result
in PHP trying to open the file along the standard include path as per
the include_pathdirective.
This is used for local files, not URLs.
Return value
Typearray|false
Returns an array with all the parsed meta tags.
The value of the name property becomes the key, the value of the content property becomes the value of the returned array, so you can easily use standard array functions to traverse it or access single values. Special characters in the value of the name property are substituted with '_', the rest is converted to lower case. If two meta tags have the same name, only the last one is returned.
Returns false on failure.
Changes to the get_meta_tags Function
PHP 8.0
- Return type added:
array|false - Parameter type added for parameter #1 (
$filename):string - Parameter type added for parameter #2 (
$use_include_path):bool - Parameter default value added for position #2 (
$use_include_path):false
- get_meta_tags($filename, $use_include_path)
+ get_meta_tags(string $filename, bool $use_include_path = false): array|false get_meta_tags Function Availability
get_meta_tags Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Security-Fixes Only | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Unsupported | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |