Undefined class constant ‘%s::%s’

Description

The requested class constant doesn’t exist.

In the case of an enumeration, this error message is also displayed for the cases: they do have the same syntax, so it is not possible to know if it is a constant or a case.

Example

<?php

class X {}

echo X::Y;

enum E { case A;}

echo E::B;

?>

Literal Examples

  • Undefined class constant ‘x::Y’

  • Undefined class constant ‘e::B’

Solutions

  • Find the actual name of the requested class constant.

  • Find the actual class of the requested class constant.

  • Define the class constant in the class, or its traits, interfaces or parents.

In more recent PHP versions, this error message is now Undefined constant %s::%s.