Teach you how to add a variable to a PHP string _php tutorial

Source: Internet
Author: User
We're on theHowever, it is necessary to add a variable description to the PHP string, although there is no error in the following example:

 
  
  
  1. Php
  2. $ Temp Array("one" => 1, "one" => 2);
  3. Output:: The first element is 1
  4. echo "The first element is $temp [one].";
  5. ?>

However, if there is no double quotation mark in the back of the Echo statement, it is necessary to give an error, so we recommend using curly braces:

 
  
  
  1. Php
  2. $ Temp Array("one" => 1, "one" => 2);
  3. echo "The first element is {$temp [" one "]}.";
  4. ?>

These are the specific workarounds for adding variables to the PHP string.


http://www.bkjia.com/PHPjc/446370.html www.bkjia.com true http://www.bkjia.com/PHPjc/446370.html techarticle we are right but need to add a variable to the PHP string description, although the following example is not error:? php $ temp = Array ("One" = 1, "two" = 2);//output:: Thefirstelementis1 ...

  • Related Article

    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.