What are the advantages of using sprintf instead of concatenating strings?

2

I know the sprintf function is for formatting strings and can replace concatenation. I can see one advantage: readability. But the other advantages I can not see.

Besides readability (due to separation), what are the other advantages of sprintf() in relation to concatenation? Is there an advantage when translating apps?

    
asked by anonymous 05.10.2018 / 16:14

1 answer

1

The advantage is more of the same, readability and ease in more complex cases. Non-simple concatenations require conversions, formatting, and doing manual gives more work. And there comes another advantage derived from this, it is very easy to make mistakes doing manually, so it is a more robust form as well. Probably more efficient because it is something processed in C code and not PHP that is much slower.

If you do it right either do it from the point of view of application translation.

    
05.10.2018 / 16:18