To connect multiple strings, you must use a (.) "vertex", for example:
- <?php
- $name = "w3pop";
- echo $name.".com";
- ?>
The output above is w3pop.com.
There is a PHP string connection. When echo is followed by double quotation marks ("), it can achieve the same effect as above:
- <?Php
- $Name="W3pop"; // This sentence is the same
- Echo "$ name.com"; // variables in double quotation marks can still be displayed normally,
And automatically separated from the general string
- ?>
However, if it is a single quotation mark, it will completely output the content to the browser in the form of a string:
- <?php
- $name = "w3pop.com";
- echo '$name.com';
- ?>
$ Name.com will be displayed
PHP string connection sample code:
- <?php
- $name = "w3pop";
- echo $name.".com";
- ?>
- <br />
- <?php
- $name = "w3pop";
- echo "$name.com";
- ?>
- <br />
- <?php
- $name = "w3pop.com";
- echo '.com';
- ?>
Output result
W3pop.com
W3pop.com.com
$ Name.com
How do you know the PHP string connection method through the above Code demonstration?