Aug 15 2007

Heredocs

heredocs.jpg

Heredocs >>

You know php heredocs ?? In php print function if we need to print a data which
has a big length and size, it is very complecated to enclose whole in single
quotes or in double quotes. If there is any single quotes present inside our
data , and we are using single quotes for string representation, php compiler
will show syntax error.

In these cases we can use heredocs. <<< is the symbol
for heredocs. Heredocs starts with this symbol (<<<) and end with a
token. See example:

<?php

print <<< UPTOEND

I can write any thing here. “This is my name”.
This is a new syntax.I
can use ’single quotes’ also.
php is a good programming
language.
my website is sajithmr.com

UPTOEND;

?>

Here UPTOEND is the token. The above code will give the
output:

I can write any thing here. “This is my name”.
This is a new syntax.I
can use ’single quotes’ also.
php is a good programming
language.
my website is sajithmr.com

But the thing to remeber is never confuse with the token
(delimiter)

<?php
print <<< CATS
If you like pets, yell out:
CATS AND DOGS ARE GREAT!
CATS;
?>

This will give the output:

If you like pets, yell out:
CATS AND DOGS ARE GREAT!

TAGS:

LEAVE A COMMENT

Subscribe Form

Subscribe to Blog

Sponsors

    Advt on sajithmr.com
    Itslife Online
    Advt on sajithmr.com
    Advt on sajithmr.com

Recent Comments

  • sexasion: Best of the Best sexypicturess.blogspot.com
  • memo ezzo: live sex hot video
  • muhammadashraf44: i am ashraf from karachi i have only one girl in sex and one night plzz
  • Arun Basil Lal: Dude, The comments to this post are ever flowing in, I am gonna post some hot pics on my blog too.....
  • badar: plz send me the hot pic

Recent Readers

JOIN MY COMMUNITY!

Recent Posts