What are some best practices for structuring PHP code to avoid issues related to includes and function declarations?

One common issue related to includes and function declarations in PHP is that including files multiple times can lead to redeclaration errors. To avoid this, it's best practice to use include_once or require_once instead of include or require when including files. Additionally, organizing your code into separate files based on functionality and using namespaces can help prevent naming conflicts.

// Include file using include_once
include_once 'functions.php';

// Declare function within a namespace to avoid naming conflicts
namespace MyNamespace {
    function myFunction() {
        // Function code here
    }
}