Get multiple lines into a variable over multiple lines

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

Get multiple lines into a variable over multiple lines

Post by Stryks »

Sorry about the subject line ... I dont really know how else to describe what I'm looking for.

I've seen some code somewhere that allows you to start putting lines into a variable until you close it, or at least that is how I understood it at the time.

I'm pretty sure that at the end you had to put END; and you had to be specific about the spaces and so on or it wouldnt work.

What I'm picturing went something like ...

Code: Select all

...
...
This is text
And so is this
END;
The idea I think was that the text would appear like that when displayed.

Can anyone figure out what I'm looking for here ... I've just confused myself. :?
TheBentinel.com
Forum Contributor
Posts: 282
Joined: Wed Mar 10, 2004 1:52 pm
Location: Columbus, Ohio

Re: Get multiple lines into a variable over multiple lines

Post by TheBentinel.com »

Stryks wrote: What I'm picturing went something like ...

Code: Select all

...
...
This is text
And so is this
END;
It sounds like you're shooting for a "here document". Here's a URL that shows the syntax and describes a common way to get bitten while using them:
http://www.zend.com/tips/tips.php?id=174&single=1

Hope it helps!
Post Reply