ivarbug
12-16-2008, 08:08 PM
Hi!
I want to ask you about php performance. Not that I have any problems running my php scripts. I'm perfectionist and I just can't sleep if some things are not clear to me.
Does parsed and compiled php code get cached somewhere or the server has to parse the unchanged code over and over again for each request? How important it is to separate the code with includes to eliminate all unnecessary code?
The way I write php right now is to have 2-5 includes with helper functions (database, url functions, some functions for string cleansing and error handler) which are used on almost every request. The rest of the code is included as needed. I usually have about 50-200 php files in my projects. Each request needs only 1-5 small files.
Also I don't use OOP in php. I use includes, functions and if/else statements are the paths to the right includes. I never had a situation where I have felt that I should use OOP. I don't have any "objects" in my code. I have only one instance of an "object" usually so the underscore character can replace all "->"'s. I don't care about restricting variable scopes either. It's my all my code. Arrays and functions are my friends. If I had a class with 1000 lines of code, I would still need only 1-2 member functions of a class on a single request. It's not a program that is loaded into the memory once on a start-up.
So give me some advice, please. How to write fastest php code and whats the best way to do it? The most important thing I want to hear about is the caching of the compiled code.
Thanks!
I want to ask you about php performance. Not that I have any problems running my php scripts. I'm perfectionist and I just can't sleep if some things are not clear to me.
Does parsed and compiled php code get cached somewhere or the server has to parse the unchanged code over and over again for each request? How important it is to separate the code with includes to eliminate all unnecessary code?
The way I write php right now is to have 2-5 includes with helper functions (database, url functions, some functions for string cleansing and error handler) which are used on almost every request. The rest of the code is included as needed. I usually have about 50-200 php files in my projects. Each request needs only 1-5 small files.
Also I don't use OOP in php. I use includes, functions and if/else statements are the paths to the right includes. I never had a situation where I have felt that I should use OOP. I don't have any "objects" in my code. I have only one instance of an "object" usually so the underscore character can replace all "->"'s. I don't care about restricting variable scopes either. It's my all my code. Arrays and functions are my friends. If I had a class with 1000 lines of code, I would still need only 1-2 member functions of a class on a single request. It's not a program that is loaded into the memory once on a start-up.
So give me some advice, please. How to write fastest php code and whats the best way to do it? The most important thing I want to hear about is the caching of the compiled code.
Thanks!