Is it ok if I include many PHP file within a PHP file? What is the best practice? Or where can I learn the best basic practice of writing PHP?
Why I do this
Is because I often can change the content of each div through the PHP file instead of directly change in the main PHP file.
1 Answer 1
Based on the level of information here, this is fine, and it's standard practice in PHP to divide parts of your page into different files. Major PHP content management systems like WordPress do this.
Having sections of the page like header, menu, and footer in their own files is commonly used, as it allows you to easily reuse that code on multiple pages.
If you have a section that is only used on one page, and will only ever be used there, a separate file is not needed. But even then, it isn't clearly harmful. It may helpfully divide your code into more manageable chunks.
content 2.php
etc. actually contain?