Naming Conflict

A naming conflict appears when two structures of the same type are using the same name.

This may lead to a fatal error, when the first defined structure has priority: this happens with functions, classes, etc.

It may also lead to overwriting, when the last structure can overwrite the first one. This approach is often silently executed, leading to late surprises. This is the case with array indices, variables, methods in class hierarchies, or arguments (in older versions of PHP).

Sometimes, PHP offers a mechanism to resolve conflicts. This is the case for methods in traits.

<?php

    $a = 1;
    $a = 2; // $a is two, the first one is forgotten

    function foo() {}
    function foo() {} // Fatal error

?>

Related : Name, Functions, Class, Namespaces, Name Conventions