What are the potential pitfalls of including multiple files in PHP and how can they be avoided?

Potential pitfalls of including multiple files in PHP include namespace collisions, variable/function redeclarations, and increased complexity in managing dependencies. To avoid these issues, it is recommended to use namespaces to encapsulate code, use include_once or require_once to prevent redeclarations, and follow a consistent naming convention for files and classes.

// Example of using namespaces to avoid namespace collisions
namespace MyNamespace;

// File1.php
include 'File2.php';

// File2.php
namespace MyNamespace;

// Code here