2015-08-27 PHP Force 024. String connection operation in PHP
String connection operation in PHP read:6185Time: 2012-03-25 A simple instance of a connection to a PHP stringTime: 2013-12-30
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.
Defines a string $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;
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:
1<?PHP2 //define the string to be inserted3 $author= "Hutaow";4 5 //generate a new string6 $str= "Welcome to {$author} ' s blog! ";7 8 //Output $STR string9 Echo $str;/*Ten after the code executes, the browser page will display One "Welcome to Hutaow ' s blog!" A */ -?>
PHP Dianabol [024 section]php String connection operation (2015-08-27)