0

Please explain me and when we echo $form; then it shows. please explain this.

$form=<<<POST
<form method="post" action="">
</form>

POST;

Thanks in Advance...

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by ayesha789
0

That's a short way of assigning a variable a value that spans multiple lines and includes special characters that would normally interfere with the PHP language.

It's called NOWDOC (see http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.nowdoc)

Consider this example:

$text = <<<SPECIAL_LABEL
The quick brown
fox jumps over
the lazy dog.
SPECIAL_LABEL

This assigns the sentence (including line breaks) to the variable $text.

The syntax is:

$variable = <<<LABEL
contents go here....
LABEL

So, in your example, the value stored in $post is:

<form method="post" action="">
</form>

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.