The variant using sprintf() is quite sure that it is the slowest of all, since function calls in PHP are quite expensive, and sprintf() will have to parse the format string. Using something like echo "abc ", $n, " xyz"; , is actually compiled into three single ZEND_ECHO , which means that the output level is called several times, which can be quite slow, depending on the SAPI used. It doesn't really matter if you use echo "abc $n xyz"; or echo "abc " . $n . " xyz"; echo "abc " . $n . " xyz"; as both of them are compiled into cocatinization operations.
source share