Answer the question
In order to leave comments, you need to log in
What is more efficient - one large php file or many small ones in templates?
There is an online store that has a lot of different useful code in the catalog. What will be processed faster, what is more correct - to cram everything into one file or split into several and call as needed?
Rough example: there is a block of banners that is relevant only for one category.
It can be output directly to the file:
if( $cat = 'someCat' ) :
echo '<img src="banner.jpg">';
echo '<img src="banner2.jpg">';
echo '<img src="banner3.jpg">';
echo '<img src="banner4.jpg">';
endif;
if( $cat = 'someCat' ) :
get_template_part( 'banners.php' );
endif;
Answer the question
In order to leave comments, you need to log in
It is more efficient to carry out load testing with logging of the request processing time and the key stages of each request processing. Then, based on the results of the analysis of the logs, identify the most problematic places and correct shortcomings, errors, and so on.
And you also need to immediately correctly decompose the project and correctly design the architecture of the system. In addition, there are still such things as a database and a web server / proxy / balancer, etc., which introduce their own delays in request processing. There is also a very wonderful thing called "caching", with which there is no need to load data from disk every time. As well as a bunch of other ways to speed up PHP.
What will be processed faster,
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question