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

department is meant to be a string (to be used here as array key). Strings in PHP must be enclosed in quotes. In the days of the long past PHP was lax about using quotes for single-word strings but these days are long gone.

Therefore, it must be 'department' or "department".

The same goes for the other errors as well.

As is, it was looking for constants called department, name, email, message, etc. When it doesn’t find such a constant, PHP (bizarrely) interprets it as a string (‘department’, etc) but warns you about that. Obviously, this can easily break if you do defined such a constant later (though it’s bad style to have lower-case constants).

Leave a Comment