Use of quotes in PHP & HTML mixed writes

Source: Internet
Author: User
Tags mixed
': Single quotes
": Double quotes

1. When using single quotes to output text, the contents of quotes are all treated as text,
eg
<?php
$face = "Interview technology";
Echo ' <a href= "Http://blog.csdn.net/illman" target= "blank" > $face </a>/n<a href= "http://blog.csdn.net "target=" blank ">csdn blog</a>";
?>
The code to print to the page will be complete:
<a href= "Http://blog.csdn.net/illman" target= "blank" > $face </a>/n<a href= "Http://blog.csdn.net" target= "Blank" >csdn blog</a>

PS: This time, the variable ^ ^ will only be directly when the text output, and not replaced by the relevant value "interview technology", while the escape character "n" line break, will be directly output, not converted to the target character

2. When you use double quotes to output text,
eg
<?php
$face = "Interview technology";
echo "<a href=/" http://blog.csdn.net/illman/"target=/" blank/"> $face </a>/n<a href=/" http:// blog.csdn.net/"target=/" blank/">csdn blog</a>";
?>
The code to print to the page will be like this:
<a href= "Http://blog.csdn.net/illman" target= "blank" > Interview technology </a>
<a href= "http://blog.csdn.net" target= "blank" >csdn blog</a>

PS: Here we can see that when we use double quotes, the variable ^ ^ is replaced with the variable "interview technique" when it is printed to the screen, and the "n" line symbol is converted into a newline. However, the double quotes of the tagged values in HTML are sensitive, so it is Or you can use single quotes instead, HTML tags in the value of the double quotes, so as to avoid the symbol sensitivity.

3. Looking at the difference between the single and double quotes in the PHP page, we can reasonably deploy when the single quotation mark is used, and when the double quotes are used. Thus making it more efficient for you to write programs.

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.