Php víceřádkový řetězec

Příklady kódu

5
0

php heredoc

	$output = <<<HTML
	<p>Lorem ipsum dolor sit amet consectetur<p>
	<a href="{$foobar}">click here</a>
HTML;
3
0

php více řádků řetězec

//use EOD function for multiple line variable
$variable=<<<EOD
  this is line1
  this is line2
  EOD;
1
0

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

0
0

Napište víceřádkové řetězce v PHP

phpCopy<?php
echo("This is the first line \r\nThis is the third line");
?>
0
0

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

V jiných jazycích

Tato stránka je v jiných jazycích

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................