Skip to content

What does the PHP error message "Notice: Use of undefined constant" mean?

The PHP error "Notice: Use of undefined constant" means that you are trying to use a constant that has not been defined yet. A constant is a value that cannot be changed once it has been set. In PHP, you can define a constant using the define() function. For example:

There are a few ways you can try to resolve this issue:

Defining a PHP constant

php
define("MAX_VALUE", 100);

This defines a constant named "MAX_VALUE" with a value of 100.

If you try to use a constant that has not been defined, you will get this error. For example:

Fixing the PHP error message "Notice: Use of undefined constant"

php
echo MAX_VALUE; // This will work
echo UNDEFINED_CONSTANT; // This will trigger the "Notice: Use of undefined constant" error

To fix this error, you need to either define the constant that you are trying to use, or make sure that you are using a constant that has already been defined.

Dual-run preview — compare with live Symfony routes.