In the context of PHP class nesting and inheritance, what are common pitfalls that can lead to errors like "Cannot redeclare class"?

When dealing with PHP class nesting and inheritance, a common pitfall that can lead to errors like "Cannot redeclare class" is accidentally including a file that declares a class multiple times. This can happen when using include or require statements in multiple files that are then included in the same script. To solve this issue, you can use the PHP function `class_exists` to check if a class has already been declared before including the file.

if (!class_exists('ClassName')) {
    require_once 'path/to/ClassName.php';
}