Friday, 5 July 2013

what is a heredoc in PHP? want to know read this post

I know many will be curious to know

what is heredoc?


Although I'm expert in PHP I don't know heredoc?

When we learn a new language we will leave some good concepts in that by mistake..

Don't worry here is a short post for you about this

Heredoc was introduced to store large or long text in a variable.

We could do that with a ordinary variable also?

Advantage with heredoc is we can freely use single or double quotes, where ever you need with out a need to remove its special meaning using black slash.

Just use a delimiter which ever you like to specify start and end of the text.

Ex:
               $myheredoc=<<<delimiter
               hi,welcome to "wetechies blog",
               Thanks for visiting :).
               delimiter;

ps: the use of word delimiter is to state the start and end of the
text. Replacing it with any word will not be a problem.

Now if you echo $myheredoc

You will see whole text you have stored..

Impressing right?

 Any doubts? or suggestion please feel free to comment :)

1 comment:

  1. Nice blog...Very useful information is providing by ur blog..here is a way to find.
    Offshore Yii Developers in India

    ReplyDelete