File: BusinessTest.php

Recommend this page to a friend!
  Classes of Stefan Kientzler  >  PHP Generate Json LD  >  BusinessTest.php  >  Download  
File: BusinessTest.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: 11 months ago
Size: 1,933 bytes



Class file image Download
use SKien\JsonLD\JsonLDLocalBusiness;


$oJsonLD = new JsonLDLocalBusiness('SportsActivityLocation');
$oJsonLD->setInfo('Sportsclimbing SC', '', '12345 67890');
$oJsonLD->setDescription('Sportsclimbinbg indoor and outdoor for everyone');
$oJsonLD->setAdress('Street 12', '12345', 'MyTown', '', 'Germany');
$oJsonLD->setLocation(48.3365629, 7.8447896, ',7.8447896,156m/data=!3m1!1e3!4m5!3m4!1s0x47912e4949b57841:0xc26f08dacee0a1a9!8m2!3d48.3367173!4d7.8441243');
$oJsonLD->addImage('elephpant.png'); // use bigger image - only for test purposes to avoid warning from test tool

// and create department...
$oDepartment = new JsonLDLocalBusiness('Organization', true);
// at least the @id MUST be other than the base-id!
$oDepartment->setInfo('Sportsclimbing SC - Outdoor Center', '');
$oDepartment->setAdress('Another street', '12345', 'MyTown');

<!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 - Local Business</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);?>

For more information send a message to info at phpclasses dot org.