Is there a specific order or hierarchy that should be followed when including files in PHP to prevent errors?

When including files in PHP, it is important to follow a specific order or hierarchy to prevent errors related to undefined functions or variables. The recommended order is to include files containing functions or classes before including files that use them. This ensures that the necessary functions or classes are defined before they are called, preventing any errors.

// Include files with functions or classes first
include 'functions.php';
include 'classes.php';

// Include files that use the functions or classes
include 'main.php';