Difference between Single and Double quotation marks in PHP

Source: Internet
Author: User

PHP's single quotes and double quotes are not the same as C #, Java, HTML, and Js. PHP single quotes and double quotes are different.

PHP:

Single quotes ('') indicate the output as is. That is to say, the variable name or any other text will be sent to the client without modification.

The variable name in double quotation marks ("") is replaced by the variable value.

For example:

     <?  PHP
$ Time = Date ( ' Y-m-d h: I: S ' );
Echo ' Time: $ time ' ; // Print: Time: $ time
Echo ' <Br/> ' ;
Echo " Time: $ Time " ; // Print: Time: 17:01:20
?>

We can see that the variables in double quotation marks are replaced before they are declared, while the variable names in single quotation marks are output as they are.

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.