Dynamic class names are not allowed in compile-time class constant references

Description

It is not possible to create a constant while using a variable, or similar containers. The expression must be static.

Example

<?php

$foo = 'a';
const A = $foo::C;

?>

Solutions

  • Use define().

  • Make the value expression static.