Constant %s already defined

Description

When a global constant is defined again, PHP reports a warning, and ignores the second definition.

This error applies to global constants only: class constants emit a fatal error, and a different message.

Example

<?php

const A = 1;
const A = 2;

echo A;

define('A', 3);
echo A;

?>

Literal Examples

  • Constant A already defined

Solutions

  • Remove the second definition.

  • Remove the first definition.

  • Fix the name of one of the constants.

  • Check if there are no missing namespace.