QBRADQ 0 Report post Posted August 12, 2005 Hello there.Most of my programming experiance has been with compiled languages. However, I am now working in PHP.In a compiled languages (or even a client-side scripting language), include directive only effect the preformance at compile-time. It has always been my style to make all global variables, functions, and data structures available to all source files by including a header file that would then in turn include all the project's headers in the correct sequence.Now, as I have said, I am working in PHP. The design of my page is that of a program, with the <body> block treated as the main execution loop. Session data is used to carry volitile data from loop to loop. Global variables and definitions are used to hold static data, and a database is used to store data that should persist from sessoin to session.Now, here's my consern: I am using include directive at the top of the main page to include all of my global variables and functions so that the page will have access to them all. But now I am beginning to wounder if that is such a good idea with a server-side script, from a preformance point of veiw.My question: Does anyone know if PHP scripts are held in memory from execution to execution, or if all the files are read from disk with each invokation? If the latter is so, I could see a definite need to include variables and functions on-demand, rather than en-mass.Any comments or suggestions would be welcome.QBRADQ Share this post Link to post Share on other sites
vizskywalker 0 Report post Posted August 12, 2005 Since the script is executed by the server at command and with certain input from the client (usually), I believe that all variables, files, etc. are read at run time, especially since they may change. But when MasterComputers gets on he will definitely have the answer.~Viz Share this post Link to post Share on other sites
Hercco 0 Report post Posted August 14, 2005 I understand there is some setting in php.ini which makies php to keep the included pages in memory and not reading it everytime from the disk. I don't know what the setting is, because I don't have own server and don't thus really get to tinker with them all that lot. So yeah, better wait thill MasterComputers sees this thread Share this post Link to post Share on other sites
QBRADQ 0 Report post Posted August 16, 2005 Either way, I have restructure my scripts to include function definitions on a need-to-know basis. I've also put in provisions for the variable sets, but at this time all global variables are needed by nearly all pages, so I've kept them included at the top of the index page.It's nice to know that there may be a way to improve the preformance of the all-inclusive design. But when it gets down to it that design ingnores one of the key features of module-oriented design, which is a principle aspect of scripted languages.I supose it's a bad habit that I need to break myself of anyway.QBRADQ Share this post Link to post Share on other sites
Hercco 0 Report post Posted August 22, 2005 By the way, can't you compile ASP scripts? That'd be a nice option for PHP too, in case you have lot of includes. Come to think about it, you could write a software that'd process PHP code so that includes would be replaced with the file contents. Could be one run on thr server after you have uploaded the files. Share this post Link to post Share on other sites