Software Programs and Projects

This Software Programs and Projects include programing tips and technology using different languages like VC++,ASP,JSP C#.Net,PHP,VB.Net,JavaScript,ASP.NET .Software Programs and Projects blog mainly support to software programmers and provide help through the mail.

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 is okay 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 is okay 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

0 comments:

Post a Comment

Post a Comment