SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    E-business guru Eirik's Avatar
    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 !
    Sincerely,

    Eirik Johansen
    Netmaking AS

  2. #2
    Not Bad, eh? Justin Sampson's Avatar
    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...

  3. #3
    E-business guru Eirik's Avatar
    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?
    Sincerely,

    Eirik Johansen
    Netmaking AS

  4. #4
    Non-Member
    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!"
    '
    ;
    ?>
    hope that helps

  5. #5
    Dumb PHP codin' cat
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •