SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
Thread: Several lines into one variable
-
Mar 22, 2001, 14:53 #1
- Join Date
- Nov 2000
- Location
- Oslo, Norway
- Posts
- 413
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi,
Quick question: What's the easiest way to store several lines of information into a variable. I can of course do the following:
$information =
"Some information" .
"Some information" .
"Some information" .
"Some information" .
"Some information";
...but I'm looking for some way to get rid of the quotes, and not having to escape them in the text I'm storing. Is there any way to do this?
Thanks in advance !
-
Mar 22, 2001, 15:26 #2
- Join Date
- Aug 2000
- Location
- N.S., Canada
- Posts
- 487
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Well, I just go like this:
$val = "some text
and more and more
";
It seems to work for me...
-
Mar 22, 2001, 15:30 #3
- Join Date
- Nov 2000
- Location
- Oslo, Norway
- Posts
- 413
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi Justin,
That might work, but then I'd still have to escape the quotes, and that get get pretty boring pretty quick.
Any other suggestions...anyone?
-
Mar 22, 2001, 15:52 #4
- Join Date
- Apr 2000
- Location
- Waco, Texas.
- Posts
- 188
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You could always use single quotes (')
PHP Code:<?
echo $quotes = '
"I have a pen"
"I have two dogs"
"I eat cheese"
"I am a boy!"
';
?>
-
Mar 22, 2001, 15:58 #5
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Rob, but then yo ucan't use variables in the string with out concatenating them in. This is where I like to use printf()
$var = sprintf('
Some text %s some "more" text and %s some more %s
so this should "show" you how it works
', $var1, $var2, $var3);Please don't PM me with questions.
Use the forums, that is what they are here for.
Bookmarks