I'm starting to incorporate heredocs into my code because of the benefits described herein: What is the advantage of using Heredoc in PHP ?
I was wondering if heredocs are slower than using echo with escapes, especially when it comes to thousands of lines of code and other operations such as a DB query, file I/O, a loop over a moderately-sized collection, etc. (thanks @delnan). By "much" I mean if it's enough of a performance issue that most seasoned programmers don't use it for big projects [e.g. creating a CMS]. I've attempted a test below.
EDIT
Granted the difference is microseconds and the test below is not a great example (I was just trying to figure it out myself), but my question is not specifically referring to just echoing strings.
$echoStmt = "The point of the \"argument\" was to illustrate the use of here documents";
$l = 100;
$start = microtime(TRUE);
while( $l-- ) {
echo $echoStmt;
}
$end = microtime(TRUE);
$diff = $end - $start;
echo $diff;
// prints 24 microseconds
echo " | ";
$l = 100;
$start = microtime(TRUE);
$heredocStmt = <<<EOF
The point of the "argument" was to illustrate the use of here documents
EOF;
while( $l-- ) {
echo $heredocStmt;
}
$end = microtime(TRUE);
$diff = $end - $start;
echo $diff;
// prints 220 microseconds