Quote:
I've seen in the Internet that it's much better to store all I want to show in a string variable and then show it at once and not echoing all the parts little by little...
There is many aspects.
I don't see a point to build a very large string and echo it at once.
If I build a table, I would echo once per row.
Strings:
Strings directly a chink of continuous memory, this mean that every time you happen a little chunk of string to a bigger one, it involve a copy of both parts, the problem is that it degenerate very quickly.
Example: you must concatenate 100 little strings (same size), it will involve copying 5050 the size of a little string.
String builder:
This object is conceived to avoid endless copy of previous part of string, thus having a vastly better runtime.
Echo/write to file
is tailored to handle small chunks of writing, so it will not particularly worse than 1 single huge write.
The advantage of small chunks is to avoid huge memory hog.