In what circumstances is it best to create a new php file? Do most dynamic php websites have multiple php files (one per form or dynamic html page for example) or is it better to have lots of php functions lumped into the one php file? Also, Im reading a book which says that "as a php application executes it moves from one web page to another (in the context of include files)". Can someone explain this for me? Im new to all this stuff - fascinating but challenging for a noob! Cheers
In building a web application there is no single common architecture. Do what is best for you. I usually use a single entry point and page controllers for smaller sites (for large modular system). In the projects, running under heavy load, I collect the overall functionality into a single file.
Omg, why????? To spare some milliseconds of disk access? Which becomes irrelevant as in heavy load sites you should put an object cache... We split into many files for better organization and maintenance. All major PHP frameworks split their code into a gazillion files. They should know something.
I look at it as a way to organize code. My structure is usually having one main file and from that, it loads all sub-level files needed. Having all these files in one file is not always convenient as it can become a real mess. Who wants to go through 1000's of lines of code in search for a single line when you can divide that by separate files that are documented? One line of code, is indeed one line, one file, it's up to you.
Yes. With 1000+ users online a couple of milliseconds is a lot. My projects consist of multiple files. Core file is generated automatically by special script. core + php accelerator + memcache allows me to generate common page in 2-5 ms
Always keep functions with similar function in one file. For example, create one file to collect functions/class for managing database etc.