🚀 DevOps & SRE Certification Program 📅 Starting: 1st of Every Month 🤝 +91 8409492687 🔍 Contact@DevOpsSchool.com

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

How to define String in PHP?

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);
?>

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.