I know the difference between include and require by reading at following link;
Require VS Include
But if there are PHP files;
- dbconenction.php (which has all the database related code)
- index.php (which has form and
dbconenction.phpis include in it to fetch some information from database. - funtions.php (which has all the custom functions which also has the
dbconenction.phpinclude or require because in some functions there are queries) - site.php (which has all the site setting fetching from database and
dbconenction.phpis include or require in it) - config.php (a file which has some manually added variables)
- email-functions.php (a file which has email templates and send email functions and
dbconenction.phpandclass.phpmailer.phpis include or require in it) - class.phpmailer.php
- process.php (where i process the form, variables, functions and send email)
So in process.php i have to include or require all files like dbconenction.php, funtions.php, config.php, email-functions and class.phpmailer.php.
My Questions;
- If
dbconenction.phpalready exist in otherPHP included or required filesdo i really need to include or require it inprocess.php? - If I don't include
class.phpmailer.phpinemail-functions.phpthen which file comes first inprocess.php?class.phpmailer.phpOremail-functions.php - And If I dont include or require
dbconenction.phpin any of above file besideindex.phpandprocess.phpthen which files comes first and which next to it incase if one PHP file variable is dependent on other PHP file;
Reason I'm asking because I develop multiple sites in php with total custom solutions but this PHP file structure always bother me and in somecases one site PHP file structure just won't work in other site at all, sometime even no error just stuck me on blank page.