About Heredoc :

Heredoc is a robust way to create string in PHP with more lines  without using quotations…

Heredoc in php start with <<< this operator

EX.01

<?php

$string = <<<DEMO

This is a EXAMPLE

message with

heredoc.

DEMO;

echo $str

?>

Output:

This is a EXAMPLE message with heredoc.

EX.02

<?php

$name = “Guest”;

$string = <<<DEMO

Hello $name! <br/>

This is a

demo Example2

with heredoc.

DEMO;

echo $string;

?>

Output:

Hello Guest!  This is a demo Example2 with heredoc.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s