Most developers will tend to concatenate the argument to the echo function, like this:
$useful = "useful"; echo "This ".$useful." PHP blog is actually quite ".useful."!";
A more efficient way of achieving the same is:
$useful = "useful"; echo "This ",$useful," PHP blog is actually quite ",useful,"!";
It can save more than 20% in execution time, which may be just what the doctor ordered for larger projects.
It is good to remember here that echo is an input/output process, which tends to consume a lot of execution time. Therefore, at times it can be worthwhile in a script to have one long concatenated string with a single call to echo, rather than a lot of small calls to echo.
No comments:
Post a Comment