
A string is a group of characters, where a character is equivalent to a byte. This implies PHP just supports a 256-character set and subsequently doesn’t offer local Unicode support.
ex:-

Single quote (‘) :-
Single quote strings are the most straightforward approach to indicate string. Single quote is utilized to indicate string when we need the string to be actually as it is composed.
<?php | |
//Single quote String | |
$number = 123456; //This is valriable with number or value | |
$number1 = 'This is DevOpsSchool'; | |
$var = 'This is Single quote String';//This is variable with value | |
echo '$number $number1 This is value'; //Output:- $number $number1 This is value | |
echo '<br>'; //This is line break | |
echo $var; // Output:- This is Single quote String | |
?> |
Here, used single quote string so not displayed or output your data value. Here work as a string. If you want to print correct data value then add in Double quote string.
Double quote (“):-
Double quoted strings are used to print any value of a variable in PHP. It will show a large group of got away characters, and variables in the strings will be assessed. A significant point here is that you can use curly braces to isolate the name of the variable you want to be evaluated.
<?php | |
//Double quote String | |
$number = 123456; //This is valriable with number or value | |
$number1 = "This is DevOpsSchool'"; | |
$var = "This is Single quote String";//This is variable with value | |
echo "$number $number1 This is value"; //Output:- 123456 This is DevOpsSchool' This is value | |
echo "<br>"; //This is line break | |
echo $var; // Output:- This is Single quote String | |
?> |
Here, Double quote string uses to print or display variables of data.
Heredoc (<<<):- It works similarly as the double quote.
<?php | |
//Heredoc String | |
echo <<< MYDATA | |
This is heredoc | |
example in php | |
MYDATA; // Output:- This is heredoc example in php | |
echo "<br>"; // Output:- This is line break | |
echo <<< DATA | |
This is heredoc second | |
example in php. | |
DATA; //Output :- This is heredoc second example in php. | |
?> |
Here, used heredoc syntax in this where (echo <<< ANYDATA) then, right if (echo <<< ANYDATA ) you want to any space or any tab then show error.
Nowdoc (<<<‘ ‘):- It works similarly as a single quote.
<?php | |
//nowdoc | |
echo <<< "MYDATA" | |
This is Nowdoc | |
example in PHP | |
MYDATA; | |
echo "<br>"; | |
//You can write thus, | |
echo <<< 'DATA' | |
This is Nowdoc | |
example in PHP | |
DATA; | |
echo "<br>"; | |
//You can also write thus, | |
$nowdoc = <<<'A' | |
You can also defined as. | |
A; | |
var_dump($nowdoc); | |
?> |




I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND