PHP string connection. In most cases, we need to connect several strings and display them. in PHP, strings are connected by dots, that is, periods in English. the specific usage is as follows :? When defining php, we often need to connect several strings to display them. in PHP, strings are connected by "points", that is, periods in English. ". the usage is as follows:
// Define a string
$ Str1 = "Hello World! ";
$ Str2 = "Welcome to huaow's BLOG! ";
// Separate the two strings with spaces
$ Str3 = $ str1. "". $ str2;
// Output the connected string
Echo $ str3;
/*
After the code is executed, the browser page is displayed.
"Hello World! Welcome to huaow's BLOG! "
*/
?>
There is another way to connect the string, which is a bit like the placeholder "printf" in C, but PHP directly writes the variable name to the placeholder. In this way, braces are added before and after the variable. when the variable is displayed, the portion of the string that is not enclosed by braces will still be directly output, the enclosed part will replace the corresponding string according to the variable name. You can see the following example to make it clearer. pay attention to the underlined part:
// Define the string to be inserted
$ Author = "huaow ";
// Generate a new string
$ Str = "Welcome to {$ author}'s BLOG! ";
// Output $ str string
Echo $ str ;/*
After the code is executed, the browser page is displayed.
"Welcome to huaow's BLOG! "
*/
?>
From: Shine's holy heaven
Why :? Php // definition...