phpapacheechoload-time

Does extensive use of php echo statement make page load times slower?


I know this question has been asked before but I haven't been able to find a definitive answer.

Does the overly use of the echo statement slow down end user load times?

By having more echo statements in the file the file size increases so I know this would be a factor. Correct me if I'm wrong.

I know after some research that using php's ob_start() function along with upping Apaches SendBufferSize can help decrease load times, but from what I understand this is more of decrease in php execution time by allowing php to finish/exit sooner, which in turn allows Apache to exit sooner.

With that being said, php does exit sooner, but does that mean php actually took less time to execute and in turn speed things up on the end user side ?

To be clear, what I mean by this is if I had 2 files, same content, and one made use of the echo statement for every html tag and the other file used the standard method of breaking in and out of php, aside for the difference in file size from the "overly" use of the echo statement (within reason I'm guessing?), which one would be faster? Or would there really not be any difference?

Maybe I'm going about this or looking at this wrong?

Edit: I have done a bit of checking around and found a way to create a stop watch to check execution time of a script and seems to work quit well. If anybody is interested in doing the same here is the link to the method I have chosen to use for now.

http://www.phpjabbers.com/measuring-php-page-load-time-php17.html


Solution

  • Does the overly use of the echo statement slow down end user load times?

    No.

    By having more echo statements in the file the file size increases so I know this would be a factor. Correct me if I'm wrong.

    You are wrong.

    does that mean php actually took less time to execute and in turn speed things up on the end user side?

    No.

    Or would there really not be any difference?

    Yes.

    Maybe I'm going about this or looking at this wrong?

    Definitely.

    There is a common problem with performance related questions.
    Most of them coming up not from the real needs but out of imagination.
    While one have to solve only real problems, not imaginable ones.