Collision
A collision, or name collision, happens when two entities of the same type have two distinct definitions. This usually leads to a PHP Fatal error, as the engine can’t tell the difference between the two structures.
Note that structures of different types may have the same name, although it might lead to ambiguities.
Structures with the same name, and defined in different namespaces are possible. The naming collision may happen at import time, a.k.a. with a use expression, and may be solved with an alias.
Some structures resolve collisions by simply overwriting the previous one: this is the case for variables.
<?php
function trumpet() {}
// name collision: no two functions can have the same name
// name collision: function names are case insensitive, so trumpet === TRUMPET
// function TRUMPET() {}
// TRUMPET as a constant and TRUMPET as a function are distinct elements.
const TRUMPET = 1;
// variable collisions are silent : the variable's value is simply changed
$trunk = 1;
foreach($herd as $trunk) {
print $trunk; // may print a different value than 1
}
?>