Skip to end of metadata
Go to start of metadata

Not yet supported

The define() function is not yet supported by TSPHP.

Not supported

PHP allows to define constants with the same name as the name of keywords (some keywords are protected and the definition of a constant with the same name as one of these names would cause a fatal error).

TSPHP does not allow constants with the same name as a name of any keyword, since it can be very confusing and thus error prone.

Unfortunately it is not mentioned in PHP's language reference, but PHP also supports the const keyword to define global constants (since PHP 5.3).

Following some examples how constants can be defined using the const keyword

const int SPACE = 10;

It is possible to declare several constants (of the same type) in the same statement using a comma (,) as separator

const float A4_WIDTH = 21.0, A4_HEIGHT = 29.7; 

Fall-back

As with functions, PHP has implemented a fall-back behaviour for constants. If a constant cannot be found in the current namespace, then PHP will search it in the global default namespace. TSPHP implements the same behaviour.

  • No labels