Table of Contents


blankNode()  : BlankNodeInterface
Creates a new RDF blank node.
defaultGraph()  : DefaultGraphInterface
Returns an RDF default graph object.
literal()  : LiteralInterface
Creates a new RDF literal.
namedNode()  : NamedNodeInterface
Creates a new RDF named node.
quad()  : QuadInterface
Creates a new RDF quad.
quadNoSubject()  : QuadNoSubjectInterface
Creates a new RDF quadNoSubject.



Creates a new RDF literal.

public static literal(int|float|string|bool|Stringable $value[, string|Stringable|null $lang = null ][, string|Stringable|null $datatype = null ]) : LiteralInterface

If the $datatype is null or empty, it must be set according to the $value and $lang parameter values:

  • if $lang is not empty, the $datatype must be set to
  • if $lang is empty or null, the $datatype depends on the PHP type of the $value parameter:
    • bool -
    • int -
    • float -
    • string -
    • Stringable object - or any other more precise XSD datatype if the implementation is able to derive it from the object class

The created literal must have valid combination of datatype and lang tag (meaning the datatype is rdf:langString if and only if the literal has a lang tag). It's up to the implementation how to assure it. Both throwing an exception and one of $lang/$datatype taking precedense over the other are considered valid solutions. Of course the implementation behavior should be documented.

See for a reference.

$value : int|float|string|bool|Stringable

Literal's value. Only values which can be casted to a string are allowed so it's clear how to obtain literal's value lexical form (see the RDF specification mentioned above). The lexical forms of scalar values must be created (returned by the getValue() method) in a way that back-casting them to the scalar type gives an equal value (probably the only tricky case here is boolean false).

$lang : string|Stringable|null = null

Literal's lang tag. If null or empty string, the literal is assumed not to have a lang tag (as an empty lang tag is not allowed in RDF).

$datatype : string|Stringable|null = null

Literal's datatype. If it's null, the datatype must be assigned according to the $lang and $value parameter values. The detailed procedure is described above.

Return values

On this page

Search results