PHP code example of bjuppa / metatagbag

1. Go to this page and download the library: Download bjuppa/metatagbag library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bjuppa / metatagbag example snippets


use Bjuppa\MetaTagBag\MetaTagBag;

$bag = new MetaTagBag(
  ['name' => 'description', 'content' => 'A description'],
  ['name' => 'keywords', 'content' => 'key,words']
);

// ...or using a static creator:

$bag = MetaTagBag::make(
  ['name' => 'description', 'content' => 'A description'],
  ['name' => 'keywords', 'content' => 'key,words']
);


$bag = new MetaTagBag(
  [
    ['name' => 'description', 'content' => 'A description'],
    ['name' => 'keywords', 'content' => 'key,words'],
    [
      ['name' => 'nested', 'content' => 'This will end up in the top-level with the other tags'],
    ]
  ]
);

MetaTagBag::make('[{"name":"description","content":"A description"},{"name":"keywords","content":["key","words"]}]');

MetaTagBag::make(new MetaTagBag(['name' => 'description', 'content' => 'A description']));

// Return a string of HTML tags from the bag's contents
$bag->toHtml();

<head>
{{ Bjuppa\MetaTagBag\MetaTagBag::make(['name' => 'description', 'content' => 'A description']) }}
<title>Page title</title>
</head>

echo $bag; //Implicit string casting
$html = (string) $bag; //Explicit string casting