2017 © Pedro Peláez
 

library htmlmeta

HTML meta reader/writer

image

mauris/htmlmeta

HTML meta reader/writer

  • Thursday, July 11, 2013
  • by mauris
  • Repository
  • 1 Watchers
  • 5 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

HtmlMeta

HtmlMeta provides abstraction for HTML meta tag reading and writing in PHP. You can directly use this library to generate out or parse meta tags in HTML content, or use OpenGraph or Twitter Cards implementation of HtmlMeta to enrich your Search Engine Optimisation and user experience., (*1)

Installation

You can install HtmlMeta via Composer as mauris/htmlmeta. See https://packagist.org/packages/mauris/htmlmeta., (*2)

Writing <meta>

<?php

use HtmlMeta\Writer;

$writer = new Writer();

$writer->add(new Meta(array('charset' => 'utf8')));
$writer->add(new Meta(array('name' => 'description', 'content' => 'some description')));

echo $writer->render();

Outputs to:, (*3)

<meta charset="utf8" />
<meta name="description" content="some description" />

Reading <meta>

<?php

use HtmlMeta\Reader;

$reader = new Reader();
$data = $reader->parse(file_get_contents('http://www.nytimes.com/2013/07/09/world/middleeast/egypt.html'));
print_r($data);

Outputs to:, (*4)

Array
(
    [0] => HtmlMeta\Meta Object
        (
            [attributes:protected] => Array
                (
                    [http-equiv] => Content-Type
                    [content] => text/html; charset=utf-8
                )

        )

    [1] => HtmlMeta\Meta Object
        (
            [attributes:protected] => Array
                (
                    [itemprop] => inLanguage
                    [content] => en-US
                )

        )

    [2] => HtmlMeta\Meta Object
        (
            [attributes:protected] => Array
                (
                    [itemprop] => description
                    [name] => description
                    [content] => In a sharp escalation of tensions Monday, Egyptian soldiers opened fire on hundreds of supporters of Mohamed Morsi, the ousted president, witnesses said. The military said armed assailants fired first.
                )

        )
...
)

The Versions

11/07 2013

dev-master

9999999-dev

HTML meta reader/writer

  Sources   Download

BSD-3-Clause

The Requires

 

11/07 2013

1.0.0

1.0.0.0

HTML meta reader/writer

  Sources   Download

BSD-3-Clause

The Requires