I was just wondering that separating header, navigation, layout, sidebar, footer into apart pages and with php include function managing them just to be able to reduce time of work is bad approach? Bad influence on performance?
This will have such a minimal impact (if any) on overall page load performance that it is not worth considering until you are probably serving millions of requests per minute, at which point you would probably have already switched to a compiled language.
This should never be a determining design factor in PHP unless you are just doing something silly like breaking your code up into thousands of includeable files which need to be loaded.
Do what makes your code more maintainable.
no, it's always additional file open operation but if it's just separated header/footer/sidebar - you really have nothing to worry about ;)
The processor load/time to include a page is so small that you won't notice it. It doesn't even register on my machine - and it is a single CPU with a single core, not a fancy web server.
Including a file is definitely a performance hit*, but it will be incredibly tiny and miniscule compared to the time saved in developing and maintaining nicely modularized code.
* The performance hit will be noticeable if you include thousands of files. If you're including a few files, the extra CPU/IO cycles it takes won't be noticeable.
Of course the hit performance is not that important with this kind of include but be careful to not include too many script because making an I/O has always a cost.
You can use some cache like APC to be sure that the code does not make to many I/O.
In this case you will not worry but when you'll write more complicated code and I'm sure you will :) you will find it good advice I hope.
Just have a look at thi bench on an apache server.
When you call a simple echo "hello world";
Total transferred: 3470000 bytes
HTML transferred: 120000 bytes
Requests per second: 2395.73 [#/sec] (mean)
Time per request: 4.174 [ms] (mean)
Time per request: 0.417 [ms] (mean, across all concurrent requests)
Transfer rate: 811.67 [Kbytes/sec] received
So always think about performance hit even if the query is simple because PHP does a lot of stuff to print data.