PHP-002- [string] - the difference between single and double quotation marks

When defining a string
can be defined strings, but can only use one
may contain double quotes single quotes
may be contained in double quotes single quotes
Likewise if a single quote contains a single quote escape string, double quotes

When the string comprises a variable
double quotation marks directly explanatory variables
in single quotes is treated as normal string variable

http://www.jb51.net/article/21035.htm

<?php
$stra="Hello";
$strb='Hello';

$strc='Hello "tom" ';
$strd="Hello 'tom' ";
echo $stra,"<br>",$strb,"<br>",$strc,"<br>",$strd;

$stre="Hello \"Tom\" ";
echo "<br>",$stre;

$strf='Hello \'Tom\' ';
echo "<br>",$strf;
/***************************************************/
$strg="Tom";
$strh="Hello $strg";//可以直接解释变量
$stri='Hello $strg';//不解释变量
echo "<br>".$strh; //Hello Tom
echo "<br>".$stri; //Hello $strg
?>

 

Published 47 original articles · won praise 3 · Views 1969

Guess you like

Origin blog.csdn.net/yueyekonglong/article/details/103988231