Mixed use of single quotes and double quotes in php

Source: Internet
Author: User
For questions about how to use single quotes and double quotes in php, see how to correctly represent strings in PHP: abcdefghijklmnopqrst and abcdefghijklmnopqrst ------ solution ------------------ pairing. you can give an example .. ------ Solution: mixed use of single quotes and double quotes in php
Ask the hero how to correctly represent the string in PHP: "abc 'defg" hijklmn "opq 'rst" and the string 'ABC "defg 'hijklmn 'opq" rst'


------ Solution --------------------
Just do pairing. you can give an example ..
------ Solution --------------------
$ X = "old test ";
$ Str1 = "this is an $ X ";
Echo $ str1;
$ Str2 = 'This is an $ X ';
Echo $ str2;
------ Solution --------------------
1. enclose strings in quotation marks
2. the single quotation marks in the string enclosed by single quotation marks must be escaped.
3. the double quotation marks in the string enclosed by double quotation marks must be escaped.
------ Solution --------------------
$ Str = '"abc \ 'defg" hijklmn "opq \ 'rst "';
$ Str2 = '\ 'ABC "defg \ 'hijklmn \ 'opq" rst \'';
Echo $ str. ":". $ str2;

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.