The difference between using ',' and '.' in php
$str1 = ‘hello’;
$str2 = ‘ ‘;
$str3 = ‘world’;
$str = $str1 . $str2 .$str3;
echo $str,’
; // hello world;
// Questions for newbies, even those who have been working for half a year.
// How to use ','
echo $str1,$str2,$str3,’
; // hello world
echo $str1 . $str2 . $str3 . ‘
; // hello world
/*
This line is $str1, $str2, $str3 in memory, splicing operation,
Calculate a large string of 'hello world',
Then echo it to get the result of the judgment
echo $str1 . $str2 . $str3 . ‘
; // hello world
echo $str1,$str2,$str3,’
; // hello world
Echo is a statement, responsible for output,
You can split by ',' to output multiple variables or values at once.
In summary:
Use ‘ . ‘ to splice first and then output the whole.
Use ‘ , ‘ to output the three variables one by one.
During the interview, you will encounter this question:
In the above two cases, which one is faster and more efficient, use ',' or '.'?
Answer: Comma is faster because it saves a splicing calculation process.