What potential pitfalls should be considered when using include in PHP to access variables from another file?

When using include in PHP to access variables from another file, it's important to be cautious of variable scope collisions. If the included file declares variables with the same names as variables in the including file, it can lead to unexpected behavior or errors. To avoid this issue, you can use functions or classes to encapsulate variables and prevent scope collisions.

// file1.php
$variable = "Hello";

// file2.php
include 'file1.php';
echo $variable; // This will output "Hello"