Encodes an object or an array into JSON-LD format
JSON-LD uses the at '@' character as part of the JSON key naming convention.
Use 2 underscores '__' as a temporary namespace for naming object keys in PHP. Then, the jsonld_encode() will take care of making it an at character '@'.
jsonld_encode( $variable )
<?php
$data = new stdClass();
$data->__context = "http://schema.org";
$data->__type = "Thing";
$data->name = "Tardigrade";
$data->description = "A cuddly microscopic extremophile that looks like a bear";
echo jsonld_encode( $data );
?>{
"@context": "http://schema.org",
"@type": "Thing",
"name": "Tardigrade",
"description": "A cuddly microscopic extremophile that looks like a bear"
}