A string is series of characters, where a character is the same as a byte. This means that PHP only supports a 256-character set, and hence does not offer native Unicode support. See details of the string type.
A string literal can be specified in four different ways:
1.single quoted
2.double quoted
3.heredoc syntax
4.nowdoc syntax
Define String With single quoted & double quoted
<?php
$t1="My Name is Virendra<br/>";
$t2="My Name is Virendra";
echo $t1;
echo $t2;
?>
Difference between single quote and double quote string in php.
A single-quoted string does not have variables within it interpreted. A double-quoted string does.
The single-quoted strings are faster at runtime because they do not need to be parsed.
Define String heredoc syntax quoted & nowdoc syntax
As you see the heredoc starts with the <<< operator and an identifier.
<?php
$str = <<<DEMO
This is a
demo message
with heredoc.
DEMO;
echo $str;
?>
Nowdoc syntax is similar to heredoc. The only difference is that the delimiter is enclosed within single quotes:
Syntax:
$myString = <<< 'DELIMITER'
(insert string here)
DELIMITER;
Traditionally, heredoc & nowdoc delimiters are written in uppercase, like constants.

0 comments:
Post a Comment