'PHP output double quotes'; Method with single quote '

  • 2020-03-31 20:40:01
  • OfStack

In PHP programming, double quotation marks "and single quotation marks" are strings and characters, so how do we output them? Let's look at a simple example of output single and double quotation marks.

Home page we look at several ways to output double quotes
Method a.
 
$str =' I'm going to print double quotes "'; 
echo $str; 

The result: I want to print double quotes"

Method 2
 
$str =" Output double quote ""; 
echo $str; 
//Result output double quote"

Output single and double quotes
 
<?php 
$str =" Output single quote '"; 
$str1=' Output single quote ''; 
echo $str; 
?> 


Variables in the middle of single quotes are not executed literally, and variables in the middle of double quotes can be executed, so it is much more efficient to output characters in single quotes without variables than in double quotes.

For special characters, you can use the transfer character "\".

Related articles: