New Lines (\n) and Single Quotes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jon Smith

    New Lines (\n) and Single Quotes

    Is there anyway to make new lines in single quotes?

    Thanks,

    Jon Smith


  • Andy Hassall

    #2
    Re: New Lines (\n) and Single Quotes

    On Tue, 03 Feb 2004 23:28:35 GMT, "Jon Smith" <jsmith@NOSPAM. earthlink.net>
    wrote:
    [color=blue]
    >Is there anyway to make new lines in single quotes?[/color]

    $answer = 'yes,
    there is.';

    --
    Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
    <http://www.andyh.co.uk > / <http://www.andyhsoftwa re.co.uk/space>

    Comment

    • Pedro Graca

      #3
      Re: New Lines (\n) and Single Quotes

      Jon Smith wrote:[color=blue]
      > Is there anyway to make new lines in single quotes?
      >
      > Thanks,
      >
      > Jon Smith[/color]

      No, not that I'm aware of :)

      you can try:

      <?php
      define('LF', "\n"); // or 'NL' or 'NewLine' or 'LineFeed' or ...

      echo 'first line', LF, 'second line';
      // avoids (lol)
      // echo "first line\nsecond line";
      // or
      // echo 'first line', "\n", 'second line';
      ?>
      --
      --= my mail box only accepts =--
      --= Content-Type: text/plain =--
      --= Size below 10001 bytes =--

      Comment

      • Pedro Graca

        #4
        Re: New Lines (\n) and Single Quotes

        Andy Hassall wrote:[color=blue]
        > On Tue, 03 Feb 2004 23:28:35 GMT, "Jon Smith" <jsmith@NOSPAM. earthlink.net>
        > wrote:
        >[color=green]
        >>Is there anyway to make new lines in single quotes?[/color]
        >
        > $answer = 'yes,
        > there is.';[/color]

        Ah! I felt like I was missing something :-)
        --
        --= my mail box only accepts =--
        --= Content-Type: text/plain =--
        --= Size below 10001 bytes =--

        Comment

        • auntie social

          #5
          Re: New Lines (\n) and Single Quotes

          On Tue, 03 Feb 2004 23:28:35 GMT, "Jon Smith"
          <jsmith@NOSPAM. earthlink.net> wrote:
          [color=blue]
          >Is there anyway to make new lines in single quotes?
          >
          >Thanks,
          >
          >Jon Smith
          >[/color]

          You can break single-quoted strings (and double-quoted, for that
          matter) over multiple lines.

          Ex:

          <?php

          $string =
          'This is
          a string
          with newlines!';

          ?>

          But if you mean using the literal character(s) \n, then you'd have to
          do it like:

          <?php

          $string = 'This is' . "\n" . 'a string' . "\n" . 'with newlines!';

          ?>

          Which one is easier to read for you? ;)

          Comment

          • Jon Smith

            #6
            Re: New Lines (\n) and Single Quotes

            Thanks for the help, I thought that was the only way...

            JS

            "auntie social" <no@thanks.suck er> wrote in message
            news:g5f0209sbc aui4njt0bt2rdrd 2ntl66mud@4ax.c om...
            | On Tue, 03 Feb 2004 23:28:35 GMT, "Jon Smith"
            | <jsmith@NOSPAM. earthlink.net> wrote:
            |
            | >Is there anyway to make new lines in single quotes?
            | >
            | >Thanks,
            | >
            | >Jon Smith
            | >
            |
            | You can break single-quoted strings (and double-quoted, for that
            | matter) over multiple lines.
            |
            | Ex:
            |
            | <?php
            |
            | $string =
            | 'This is
            | a string
            | with newlines!';
            |
            | ?>
            |
            | But if you mean using the literal character(s) \n, then you'd have to
            | do it like:
            |
            | <?php
            |
            | $string = 'This is' . "\n" . 'a string' . "\n" . 'with newlines!';
            |
            | ?>
            |
            | Which one is easier to read for you? ;)
            |


            Comment

            Working...