PHP string connection code compilation method

Source: Internet
Author: User

To connect multiple strings, you must use a (.) "vertex", for example:

 
 
  1. <?php   
  2. $name = "w3pop";   
  3. echo $name.".com";   
  4. ?>   

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:

 
 
  1. <?Php
  2. $Name="W3pop"; // This sentence is the same
  3. Echo "$ name.com"; // variables in double quotation marks can still be displayed normally,
    And automatically separated from the general string
  4. ?>

However, if it is a single quotation mark, it will completely output the content to the browser in the form of a string:

 
 
  1. <?php   
  2. $name = "w3pop.com";   
  3. echo '$name.com';   
  4. ?>   

$ Name.com will be displayed

PHP string connection sample code:

 
 
  1. <?php   
  2. $name = "w3pop";   
  3. echo $name.".com";   
  4. ?>   
  5. <br />   
  6. <?php   
  7. $name = "w3pop";   
  8. echo "$name.com";   
  9. ?>   
  10. <br />   
  11. <?php   
  12. $name = "w3pop.com";   
  13. echo '.com';   
  14. ?>   

Output result

W3pop.com

W3pop.com.com

$ Name.com

How do you know the PHP string connection method through the above Code demonstration?


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.