Many times we need to concatenate a few strings to show that in PHP, the strings are connected using "dots", which is the period "." in English, using the following method:
Defining strings
$str 1 = "Hello world!";
$str 2 = "Welcome to Hutaow ' s blog!";
Connect the above two strings separated by a space
$str 3 = $str 1. " " . $STR 2;
Output the concatenated string
echo $str 3;
/*
After the code executes, the browser page will display
"Hello world! Welcome to Hutaow ' s blog! "
*/
?>
The connection string has another method, a bit like the "printf" placeholder in C, but PHP simply writes the variable name to the placeholder. The way to use this is to enclose the variable with curly braces, so that when displayed, the part of the string that is not enclosed in curly braces will still be output directly, and the enclosed part will be replaced with the corresponding string according to the variable name. You can see the following example more clearly, note the underlined part:
Define the string to be inserted
$author = "Hutaow";
Generate a new string
$str = "Welcome to {$author} ' s blog!";
Output $STR string
Echo $str; /*
After the code executes, the browser page will display
"Welcome to Hutaow ' s blog!"
*/
?>
Excerpt from: Shine's Sacred Paradise
http://www.bkjia.com/PHPjc/478624.html www.bkjia.com true http://www.bkjia.com/PHPjc/478624.html techarticle many times we need to concatenate a few strings to show that in PHP, the strings are concatenated using dots, that is, the period in English., using the following methods:? PHP//Definition ...