Home  >  Article  >  Backend Development  >  What is the difference between using commas and dots to connect php echo? Which one is faster?

What is the difference between using commas and dots to connect php echo? Which one is faster?

WBOY
WBOYOriginal
2016-07-29 08:56:571145browse

First go to the great article 54chen

which mentioned that it is better to use , to connect echo strings than to use .. Let’s not talk about the reasons. Let’s take a look at the following two sentences

<code> <?php
 // 逗号比.更节省时间?
  echo '1+5=' . 1+5; 
  echo '1+5=' . 5+1;</code>

What is the result?
1+5=6?
1+5=6?
——————
6?
2?
——————
6.6?
6.6?
——————
I can only say echo '5+1=' . 1+5;The result is 10, so the results are 6 and 2.

php echo manual

<code><?php
// Strings can either be passed individually as multiple arguments or
// concatenated together and passed as a single argument
echo 'This ', 'string ', 'was ', 'made ', 'with multiple parameters.', chr(10);
echo 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . "\n";
</code>

As for why it is fast, it can be easily understood. Use . to splice it into echo first, although the number of commas represents the number of echo calls (it can be understood this way for the time being).
But the splicing speed is slower than the echo speed.
If you understand it deeply, VLD is as shown below. It’s a picture of @tywei
What is the difference between using commas and dots to connect php echo? Which one is faster?

. The top has more CONCAT than the bottom, and the bottom has more echo than the top.
If you want to know more details, click to view this bombshell

The above introduces the difference between using commas and dots to connect php echo? Which one is faster? , including relevant content, I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn