In PHP three types of strings are using single quoted,double quoted,heredoc
A string literal can be specified in four different ways:
- single quoted
- double quoted
- heredoc
Single quoted
The simplest way to specify a string is to enclose it in single quotes (the character ').
echo 'this is a simple string';echo 'You can also have embedded newlines in strings this way as it isokay to do';// Outputs: Arnold once said: "I'll be back"echo 'Arnold once said: "I\'ll be back"';
<?php
echo 'this is a simple string';
echo 'You can also have embedded newlines in strings this way as it isokay to do';
// Outputs: Arnold once said: "I'll be back"echo 'Arnold once said: "I\'ll be back"';
?>
heredoc
<?php
echo <<<EOT My name is "$name".
I am printing some EOT;?>
A third way to delimit strings is the heredoc syntax: <<<. After this operator, an identifier is provided, then a newline. The string itself follows, and then the same identifier again to close the quotation. The closing identifier must begin in the first column of the line. Also, the identifier must follow the same naming rules as any other label in PHP: it must contain only alphanumeric characters and underscores, and must start with a non-digit character or underscore
tag:-rDi
fferent types of strings in php - single quoted,double quote,heredoc
