What are potential pitfalls of including multiple PHP files in a single webpage?

Including multiple PHP files in a single webpage can lead to naming conflicts, duplicate function declarations, and difficulty in debugging. To solve this issue, you can use PHP namespaces to encapsulate your code and avoid naming collisions.

// main.php
<?php
include 'file1.php';
include 'file2.php';
// Your code here
?>

// file1.php
<?php
namespace File1;
function myFunction() {
    echo "Function from file1";
}
?>

// file2.php
<?php
namespace File2;
function myFunction() {
    echo "Function from file2";
}
?>

// To call the functions from the included files, use their respective namespaces
<?php
File1\myFunction();
File2\myFunction();
?>