The difference between using ',' and '.' in php_PHP Tutorial

WBOY
Release: 2016-07-21 14:53:36
Original
913 people have browsed it

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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/371361.htmlTechArticleThe difference between ' 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. //...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!