<?php /** * This example shows how to create a literal containing a string - its datatype is set to xsd:string per default. * * We use Impl-classes here (e.g. LiteralImpl), which are implementations of the according * interface (e.g. Literal). It is also possible that you create your own implementation. */ require dirname(__FILE__) . '/../vendor/autoload.php'; // create an instance of LiteralImpl by given a string // a literal must be instanciated with a string value, and will throw an exception otherwise. $literal = new Saft\Rdf\LiteralImpl('foo'); // output the value of the literal echo PHP_EOL . 'literal: ' . $literal->getValue() . PHP_EOL;
<?php /** * This example shows how to create a literal with a string value and a language. In the current * RDF standard it is not possible to set a datatype and language freely together. It is basically * either a datatype or language. If you use a language, you must set the datatype to a certain URI. * * We use Impl-classes here (e.g. LiteralImpl), which are implementations of the according * interface (e.g. Literal). It is also possible that you create your own implementation. */ require dirname(__FILE__) . '/../vendor/autoload.php'; $stringLiteral = new Saft\Rdf\LiteralImpl('foo', new Saft\Rdf\NamedNodeImpl('http://www.w3.org/1999/02/22-rdf-syntax-ns#langString'), 'en_GB'); echo PHP_EOL . 'stringLiteral value: ' . $stringLiteral->getValue(); echo PHP_EOL . 'stringLiteral datatype: ' . $stringLiteral->getDatatype(); echo PHP_EOL . 'stringLiteral lang: ' . $stringLiteral->getLanguage() . PHP_EOL;