Output variables at the same time as the Echo string

Source: Internet
Author: User


Load variables in text, how do variables output?


1. For Python, use the Format function

Cases:

Date= "Sunday";

Print ("Today is {0}". Format (data)); Output today is Sunday


where {0}{1}{2} ..... Can have multiple, in different locations, corresponding to the format (value 1, value 2, value 3 ...) The corresponding elements in the specific please Baidu this function usage


2. For Php,echo, use double quotes "" Only to line, call the variable name directly. Single quotes ' Do not parse variables

Cases:

$date = "Sunday";

echo "Today is $date"; Output today is Sunday

Echo ' Today is $date '; Output today is $date


Also note the use of escape characters \ Match single double quotes

Example: Suppose there is a div block element with a size

$v 1= "Red";

echo "<div style=\" backgroud:# $v 1;\ ">";//Red block

echo "<div style=" backgroud:# $v 1; > ";/Error

and the single quote echo ' <div style= ' backgroud:# $v 1; > '//Output <div style= "backgroud:# $v 1;" >

In the case of single double quotes, internal single quotes, outside with double quotes echo "class= ' $v 1 '"


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.