How to connect files with php?

What is the best way to connect files with php?
I know there is include.
For example: if I have an index file and include file2.
From file2 I want to acces another file with functions.

Or even multiple files with different functions?

How are the best way to proceed?

I usually go one level deep except for the file that contains the passwords. The others are files I don’t want to repeat like the top and bottom portion of the HTML and the navigation menu as they are pretty much the same on all pages. As for functions I try to group them in categories, for example login functions file would go into one file and so on. Functions and HTML files I use include and for configuration files I use require_once.

1 Like

I think this code can help you :

<?php $FileNames = [ '1.php', '2.php', ]; foreach($FileNames as $FileName){ include $FileName; } ?>
1 Like
Sponsor our Newsletter | Privacy Policy | Terms of Service