PHP Dianabol [024 section]php String connection operation (2015-08-27)

Source: Internet
Author: User

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)

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.