PHP Classes

File: EventTest.php

Recommend this page to a friend!
  Classes of Stefan Kientzler   PHP Generate Json LD   EventTest.php   Download  
File: EventTest.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Generate Json LD
Generate metadata for HTML pages in JSON-LD format
Author: By
Last change:
Date: 3 years ago
Size: 1,875 bytes


Class file image Download
use SKien\JsonLD\JsonLDEvent;
// the autoloader will find all needed files...
require_once 'autoloader.php';

$oJsonLD = new JsonLDEvent();

$oJsonLD->setInfo('A great Concert for all...', new DateTime('2020-06-12 18:30'), new DateTime('2020-06-12 22:00'));
$oJsonLD->setDescription('... would it not be amazing, if these two musicians could perform together!' . PHP_EOL . 'Incredible.');
$oJsonLD->setAdress('Kensington Gore', 'SW7 2AP', 'London', '', 'United Kingdom');
$oJsonLD->setLocation('Royal Albert Hall', 51.5009088, -0.177366, ',-0.177366,15z/data=!4m5!3m4!1s0x0:0x5efe9cee35da2fd9!8m2!3d51.5009088!4d-0.177366');
$oJsonLD->addOffer('Seat', 80, 'GBP', $oJsonLD::AVAILABLE_PRE_ORDER, new DateTime('NOW'), '');
$oJsonLD->addOffer('VIP', 250, 'GBP', $oJsonLD::AVAILABLE_PRE_ORDER, new DateTime('NOW'), '');
$oJsonLD->setOrganizer('Queen Mum', '');
$oJsonLD->addPerformer('Elton John');
$oJsonLD->addImage('elephpant.png'); // use bigger image - only for test purposes to avoid warning from test tool
<!DOCTYPE html>
<title>Json LD Generator</title>
<!-- insert the tag in the head section of the document -->
<?php echo $oJsonLD->getHTMLHeadTag(false);?>
    <h1>Json LD Generator - Event</h1>
    <p>You can copy generated JsonLD script to test it in
        <a target="_blank" href="">
    <textarea style="font-family: 'Courier'; width: 100%; white-space: nowrap;" rows="50" spellcheck="false">
    <?php echo $oJsonLD->getJson(true);?>