php heredoc
$output = <<<HTML
<p>Lorem ipsum dolor sit amet consectetur<p>
<a href="{$foobar}">click here</a>
HTML;
php více řádků řetězec
//use EOD function for multiple line variable
$variable=<<<EOD
this is line1
this is line2
EOD;
syntaxe php <<
<?php
$str = <<<EOD
Example of string
spanning multiple lines
using heredoc syntax.
EOD;
/* More complex example, with variables. */
class foo
{
var $foo;
var $bar;
function __construct()
{
$this->foo = 'Foo';
$this->bar = array('Bar1', 'Bar2', 'Bar3');
}
}
$foo = new foo();
$name = 'MyName';
echo <<<EOT
My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should print a capital 'A': \x41
EOT;
?>
Napište víceřádkové řetězce v PHP
phpCopy<?php
echo("This is the first line \r\nThis is the third line");
?>
Napište víceřádkové řetězce v PHP
phpCopy<?php
$mystring1 = "This is the first line." . PHP_EOL;
$mystring2 = "This is the second line" . PHP_EOL;
$mystring3 = "This is the third line" . PHP_EOL;
$mystring4 = "This is the fourth line" . PHP_EOL;
$mystring5 = "This is the fifth line";
$mystring1 .= $mystring2 .= $mystring3 .= $mystring4 .= $mystring5;
echo($mystring1);
?>