Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 03:55 AM
Jon Smith
Guest
 
Posts: n/a
Default New Lines (\n) and Single Quotes

Is there anyway to make new lines in single quotes?

Thanks,

Jon Smith





  #2  
Old July 17th, 2005, 03:55 AM
Andy Hassall
Guest
 
Posts: n/a
Default 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.andyhsoftware.co.uk/space>
  #3  
Old July 17th, 2005, 03:56 AM
Pedro Graca
Guest
 
Posts: n/a
Default 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 =--
  #4  
Old July 17th, 2005, 03:56 AM
Pedro Graca
Guest
 
Posts: n/a
Default 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 =--
  #5  
Old July 17th, 2005, 03:56 AM
auntie social
Guest
 
Posts: n/a
Default 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? ;)

  #6  
Old July 17th, 2005, 03:56 AM
Jon Smith
Guest
 
Posts: n/a
Default Re: New Lines (\n) and Single Quotes

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

JS

"auntie social" <no@thanks.sucker> wrote in message
news:g5f0209sbcaui4njt0bt2rdrd2ntl66mud@4ax.com...
| 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? ;)
|


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,414 network members.