This article mainly introduces the way of the definition of PHP string and their respective differences, has a certain reference value, now share to everyone, the need for friends can refer to
Single quotation mark cannot parse variable
Single quotes cannot parse escape characters, only single quotes and backslashes themselves
Variables and variables, variables, and strings, strings, and strings can be used . Connection
Double quotation marks can parse variables, variables can use special characters and {} contain
Double quotes to resolve all escape characters
Variables and variables, variables, and strings, strings, and strings can be used . Connection
$sql = "SELECT * from user where name = ' {$name} '";-->select * from user where name = ' Lisi '
$sql = ' Select ' from user where name = \ '. $name. ' \''; Higher efficiency
Single quote efficiency is higher than double quotation mark
Functions similar to double quotation marks
$str = <<<eodexample of stringspanning multiple linesusing heredoc syntax. EOD; $str = <<< "FOOBAR" Hello world! FOOBAR;
Cannot have any other symbols before the end identifier (indent is not allowed)
Functions similar to single quotes
$str = <<< ' EOD ' Example of stringspanning multiple linesusing nowdoc syntax. EOD;