Easy bit I cant recall how it's done ...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Easy bit I cant recall how it's done ...

Post by Stryks »

... in fact, I couldnt think of a better subject line. :D

Just trying to remember how I can stream to a string.

I seem to recall it looking something like ...

Code: Select all

$value = <<STUFF

blah
blah
blah

STUFF>>
Anyone have any idea what I'm talking about?

Cheers
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

It's called HEREDOC ;)

Code: Select all

$somevar = <<<ANYWORD
Content goes here with variables escaped in
{$curly_brackets} like so but usually you don't need the
curly brackets.

The whole string gets parsed like a double quoted string across
multiple lines without the need to escape quotes.
ANYWORD;


//Or

echo <<<SOMETHING
Put the content here
however you want!
SOMETHING;

//
User avatar
harrisonad
Forum Contributor
Posts: 288
Joined: Fri Oct 15, 2004 4:58 am
Location: Philippines
Contact:

Post by harrisonad »

Next time, try to make your subject line relevant to you problem. :wink:
Post Reply