Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

New Lines (\n) and Single Quotes

1 view
Skip to first unread message

Jon Smith

unread,
Feb 3, 2004, 6:28:35 PM2/3/04
to
Is there anyway to make new lines in single quotes?

Thanks,

Jon Smith


Andy Hassall

unread,
Feb 3, 2004, 6:40:41 PM2/3/04
to
On Tue, 03 Feb 2004 23:28:35 GMT, "Jon Smith" <jsm...@NOSPAM.earthlink.net>
wrote:

>Is there anyway to make new lines in single quotes?

$answer = 'yes,
there is.';

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

Pedro Graca

unread,
Feb 3, 2004, 6:35:15 PM2/3/04
to

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 =--

Pedro Graca

unread,
Feb 3, 2004, 6:37:39 PM2/3/04
to
Andy Hassall wrote:
> On Tue, 03 Feb 2004 23:28:35 GMT, "Jon Smith" <jsm...@NOSPAM.earthlink.net>
> wrote:
>
>>Is there anyway to make new lines in single quotes?
>
> $answer = 'yes,
> there is.';

Ah! I felt like I was missing something :-)

auntie social

unread,
Feb 3, 2004, 7:34:33 PM2/3/04
to
On Tue, 03 Feb 2004 23:28:35 GMT, "Jon Smith"
<jsm...@NOSPAM.earthlink.net> wrote:

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? ;)

Jon Smith

unread,
Feb 3, 2004, 7:41:56 PM2/3/04
to
Thanks for the help, I thought that was the only way...

JS

"auntie social" <n...@thanks.sucker> wrote in message
news:g5f0209sbcaui4njt...@4ax.com...

0 new messages